Your second "for" loop


#1


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


I am SO confused.

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 = "blah Sean blah blah blah blah blah blah blah blah blah blah blah blah blah blah Sean blah blah blah blah Sean blah blah blah blah blah blah blah blah blah blah";
var myName = "Sean";
var hits = [];
for (i = 0; i > text.length; i++) {
    if (text[i] === "S") {
        for (j = i; j < i + myName.length; j++){
            hits.push("Sean");
        }
    }
}


#2

HI this line

hits.push("Sean")

you should put inside .push() text[j] instead of your name then here

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

change the > with <.


#3

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