Getting Error on This Exercise


#1


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


I am getting the error "
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."

I've even copied the working code from the beginning of the lesson but still getting an error.


/*jshint multistr:true */
var text = "blah blah Sean \
blah blah Sean blah blah \
 blah blah";
var myName ="Sean";
var hits = [];

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


#2

Hi this for loop

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

this part

i > text.length

you shoudl change the > with < ......because i will never be great than text.length


#3

Thanks so much! This was it.


#4

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