It looks like your second 'for' loop isn't pushing values to the hits array


#1

My code is as follows, is is not working:

/* jshint multistr:true */
var text = "I'm Nick";
var myName = "Nick";
var hits = [];

for(var i = 0; i < text.length; i++){

if( text[0] === "N"){

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

        hits.push(text[j]);

    }

}

}


#2

@nmanove,

-1

You will have to change your IF condition
from

text[0] === "N"

into

text[i] === "N"
or
 text[i] === myName[0]

-2

for ([initialization]; [condition]; [final-expression]) {
   statement
}

In your second FOR-loop you will have to change your condition
from

  j = (i + myName.length)

into

j < (i + myName.length)

#3

Thanks for the help. Much appreciated! :slightly_smiling: