What's wrong with this? 5/7


#1

/*jshint multistr:true */
text = "dfrdf bsdfhs jsdf Alex ddfjdg Alex dfsdg Alex";
myName = "Alex"
hits = []
for(var i = 0; i < text.length ; i++) {
if (i === text[i]);
{ for(var j = 0; j < (myName.length+1); j++)
hits.push(text[j]);
};
};
`

Interestingly enough, this code is considered "correct" by codeacademy. However, a console.log will reveal that the code is not sending the right letters into the array. It sends pretty much a random conglomerate of letters, not what it's supposed to be sending. ("Alex" when it is seen each time)

So, what's wrong with it?


#2

Remove that semicolon here:


#3

Once I remove that semicolon, I'm greeted with a codeacademy error dialog.

"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."