Your second "for" loop


#1



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


My code error says " 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."


var text = "fhsiuhfiufhos ufhhfoiafi hoae foiheoa Josh sfhuishfishfih seoifhseohfsoh Josh ohafoiheofha Josh sifheius"
var myName = "Josh"
var hits = []
for(var i = 0; i < text.length; i++) {
    if (text[i] === "J") {
        for(var j = i; j > i + myName.length; j++){
           hits.push(text[j]);   
}}}


#2

@go2001o

Don't forget to put semicolons ; at the end of each statements.:wink:


#3

the semi-colons aren't the problem


#4

the problem is that in yoer secnd for loop, you need to make j < I +myName.length

so like this:

for(var j i; j < i + myName.length; j++)

And that should do it.

NOTE: putting semi-colons at the end of sentences isn't really necessary.


#5

var text = "blah blah blah eric blah blah eric blah blah eric blah blah";

var myName = "eric";
var hits = [];

for (var i=0; i if (text[i]==="e") {
for(var j=i; j hits.push(text[j]);
}
}
}


#6

@hellofromeric

If you have a problem, please post in a new thread with your question + error message + code