OMG WTH pls help


#1

Ok I got help from someone else but now it just crashes my browser


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

/*jshint multistr:true */
var text ="My name is Saihaan and that name belongs to Saihaan.";
var myName= "Saihaan";
var hits = []
for (var i = 0; i < text.length; i++)
{
    if (text[i] === "S")
    {
        for(j = i; j > myName[0].length; j++)
        {
            hits.push(text[j])
        }
    }
}

#2

Please read the hint:

Your loop should stop when it hits the value of the first iterator (say, i) plus the length of your myName variable.

So you need something like this:

j < i + myName.length

This code:

j > myName[0].length

checks if j is greater than one. Because myName[0] is just "S".


#3

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