Please help me on 'Your second "for" loop' - Search Text For Your Name


#1



Hi,
The exercise I am stuck on is: 'Your second "for" loop' - Search Text For Your Name


The error message is: '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 = "Hey, I am Matt, that was Matt if you missed it \
-Matt.";
var myName = "Matt";
var hits = [];

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


#2

Hi thsi line

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

i will never be great than text.length so you should change the > with <


#3

Thankyou very much for your help-much appreciated :wink: