Help?


#1


var text = " na na ana nana na nana shai \ jf shai \ fdsa aad agds ";
var myName = "shai";
var hits = [];

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


#2

Try this.

`for (var j = i; j < i + myName.length; j++) {
            hits.push(text[j])
}
}
};

Your second for loop's main function is to verify and make sure that each character in the text you are trying to find is pushed into this empty list. hits = [];
So instead of pushing your desired text directly as a string. You are pushing your desired into an array like this hits.push(text[j])