Your second loop!


#1

I'm not sure of what I'm doing wrong. It gives me the error message below. The code looks right to me.
Help?

https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661

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.


var text = "The bears in the Maria game, and Goldilocks, / have porridge for breakfast. / Maria Tell us about your breakfast.";
var myName = "Maria";
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

Change > to <, as in,

    i < text.length;

#3

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