Your Second For Loop Problems


#1

Hi guys! I am having a problem. I got to this lesson, coded everything just like it told me to do, and it gave me an error saying:

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.

I have searched the Q and A forums for 35 minutes and tried everything people said to try but nothing has worked. Here is my code:

/*jshint multistr:true */
var text = "Justin will one day be a video game developer!"
var myName = "Justin"
var hits = []
for (var i = 0; i < text.length; i++) {
}
if (text[i] === "J") {
myName[0]
for (var j = i; j < i + myName.length; j++) {
hits.push(text[j]);
}
}

I honestly have no idea what I am doing wrong. Please help me!


#2

Hello there, I believe the problem was that you closed your first for loop early, so nothing executed properly.

for (var i = 0; i < text.length; i++) {
} // Move this bracket to the end of your code block

And make sure you are exercising proper web practices, it's a good idea to end your lines with semi-colons.