Your second "for" loop


#1

I need help with this topic. can you please tell me what is wrong with my code?

This is where I am stuck at

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

Codecademy's response is "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 = "Hi There";
var myName = "Paul Taylor";
var hits = [];
for (var i = 0; i < text.length; i++) {
    console.log(i);
    if (text[i] === "P") {   
        for (var loop = i; loop < myName.length + i; loop++) {
            hits.push(text[loop]);
        }
    }
}

#2

You name is not in the text variable. Make sure you type something like "blah blah blah blah blah Paul Taylor blah blah blah blah"


#3

Thanks terarunner77454.


#4

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