Your second "for" loop


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++){



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


the semi-colons aren't the problem


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.


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]);



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