Your second "for" loop


#1


Why does it say: 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.


/*jshint multistr:true */

var text = "Name text"

var myName = "My name"

var hits = []

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


#2

here:

var myName = "My name"

the name should be a single word (no spaces) and the name should be in the text string so it can be found.

Oh, and your first for loop:

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

you want to increase i while smaller then (<) the length of text, not bigger (>)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.