5/7 for loop


#1

Hello Guys:

Does anyone know what is wrong with my code:

var text = "Andres Felipe Barrera is a winner";
var myName = "Andres Felipe";
var hits = [];
for(var i = 0; i < text.length; i++){
if (text[i] === myName[0]){
for(var j = i; j < (i + myName.length); i ++) {
hits.push(text[j]);
}
}
}

Thanks


#2

@codeafp,

I believe your issue is that you're incrementing " i " in both of your for loops, instead of incrementing " j " in your second for loop.

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