Your second for loop


#1

Please someone help i'm not sure how to fix the below issue. I'm sure its something simple that i'm not seeing?

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

My error message says "Oops, try again. Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length."

var text = "The story of Phillip Beltre\
is one that is very interesting.\
To be honest, Phillip is low key a G.";
var myName = "Phillip";
var hits =[];

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


#2

This is my code and it worked you should look through and see if you can find what you did wrong:
var text = "Aaron likes pi. Aaron also like cake. Aaron likes food in general.";
var myName = "Aaron"
var hits = [];
for (var i = 0; i < text.length;i++) {
if (text[i] === 'A'){
for (var j = i; j < (i + myName.length); j++) {
hits.push(text[j]);
}
}
}


#4

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