5. Your second "for" loop


#1

var text = "My name is Tyree and you will call me Tyree.";
var myName = "Tyree";
var hits = [];
for(var i = 0; i > text.length; i++)
{
if(text[i] === myName[0])
{
for(var j = i; j < (i + myName.length); j++)
{
hits.push(text[j]);
}
}
}

I keep getting this error: Oops, try again. It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.

Need help asap


#2

Change your > sign to a < sign.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.