Second for loop not pushing values to array


#1

I'm getting the following error:

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

Been stuck here for a while...what am I doing wrong?


var text = "Hi, my name is Daniel. I happen to think that is a great name"

var myName = "Daniel"

var hits = []

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

console.log(hits)


#2

after i++) you have a unnecessary semi-colon


#3

you need to declare-> var j; put the semicolon after each var;
delete the ; for the first for loop, I think that's the issue


#4

why do we need to do this? Is it better practice? Yes. Mandatory? No


#5

This was the issue, thanks.

cloudace, the code passed without declaring var but I had not noticed that so thanks for pointing it out.


#6