Help with second for loop


I cant figure out what is wrong with the second for loop. Keep getting this error message:

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.

var text = "My name is Mckinley. asdfa adfasdf adsfasdf"

var myName = "Mckinley"

var hits = []

for(var i = 0; i <= text.length; i++);{
if(text[i] === myName[0]){
for(var j = i; j <= (myName.length + i); j++);


Take a careful look at your syntax. Your "For" loops have semicolons placed next to them when it should instead be two curly braces "{ }" to surround your code.

Remember a For loop should look like:


While you have put:


I don't know if in your code you've used indentation, but if you haven't I'd recommend doing so. Reply if you still don't understand!




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