Constantly stuck on 5/7


#1

Hi, can I have some help?

I'm repeatedly getting this 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."

I have tried and tried and now I'm stuck. Any advice on where I am going wrong will help.

var text = "My name is Gemma. My name really is Gemma. I'm being serious, it is Gemma"
var myName = "Gemma"
hits = []
for (i = 0; i === text.length; i++){

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

}
}
}


#2

@megawhiz38298 your code looks good except for one thing which is causing it not to record the hits. In your second for loop, where you have

for (var j = i; j < (myName.length + 1); j++) {

It should say (myName.length + i) since i is the starting point. Once you make that change, you should be good.