#5 your second for loop, HELP!


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#

error:Oops, try again. There was a problem with your syntax.
I have been stuck on this for a day and have no idea what i'm really supposed to be doing. Any help is greatly appreciated!

var myName = "Oscar";
var hits["Oscar"];
for(var i=0; i< text.length; i++){
if(text[i] ==="O")
{for( var j = i;j<i+myName.length; j++ )
    hits.push(text[j]);}
else
{}
}


#2

HI this line

var hits["Oscar"];

I think you should put hits equal to a empty array

var hits = [];

then you don't need of the else {} remove it .. then you should open the seconde for loop {


#3

i did the same thing...
getting the error: "Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length."
my code is:
var hits = [];
for(i = 0 ; i if(text[i] === 'p'){
for( var j=i; j<(i+text.length); j++ )
{
hits.push(text[j]);
}
}
}


#5

Hi this part

for( var j=i; j<(i+text.length); j++ )

instead of text.length you should put myName.length


#6

thank u:slight_smile: