5. Second loop: can't push the name


#1


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


It says "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 banged my head on the wall, I checked with some other well done codes and I just couldn't find the mistake.


/*jshint multistr:true */
var text = "BAUMAN Zygmunt, press Name Press"

var myName = "Name"
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

you have semi-colon after i++) which interupts the loop, remove the semi-colon


#3

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