6 Log it - Oops, try again. There was a problem with your syntax


#1

Hi - I have checked in the forum but i cant still find why i m unable to clear the level - i get this error (Oops, try again. There was a problem with your syntax.) Please help, here is my code

/*jshint multistr:true */

var text = "sachin want to be the biggest  market lord sachin want to be  biggest  market lord sachin want to be the biggest market lord";
var myName = "sachin"
var hits = [];
for (var i=0; i<text.length; i++);

    if(text[i]==="s")
{
    console.log("s");
for(var j=i; j<myName.length +i; j++)
}
hits.push(text[j]);

 if(hits.length===0);
 {
    console.log("Your name wasn't found!");
 }
 else
 { 
    console.log(hits);
 }
This is the Error i get - Oops, try again. There was a problem with your syntax.

#2

Well, it seems that your missing a good chunk of your for loops. Your creating a variable named i, setting it to 0, and then the rest of the for loop is missing. A for loop is used to loop something a determined amount of times. In your code, you would need to set your for loop to run until it reaches the length of your text variable.


#3

Hey erfwerm,
Thank you for a quick response but can you please teach it through the code? can you share the code that i m missing


#7

here is correct variant of your code check it pls, you can use external text editors for brackets and syntax errors.
`

/*jshint multistr:true */

var text = "sachin want to be the biggest market lord sachin want to be\
biggest market lord sachin want to be the biggest market lord";
var myName = "sachin"
var hits = [];
for (var i=0; i

if(text[i]==="s")

{
for(var j=i; j

hits.push(text[j]);

}}

if(hits.length===0)
{
console.log("Your name wasn't found!");
}
else
{
console.log(hits);
}
`


#8

thank you ...got it :slight_smile: