Search Text for you name 5. "Your second for loop" HELP!


#1

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


Error Message: "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 keep getting this error message but don't understand exactly what I did wrong. Can anyone help debug my code?


/*jshint multistr:true */
var text = "Food food food food food food food billy \
food food food food blah blah blah food fod billy food \
food billy food";
var myName = "Billy";
var hits = [];

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


#2

JavaScript is case-sensitive. Use the proper name in your text string.


#3

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