5. Your second "for" loop. What am I doing wrong?


#1


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

SyntaxError: Unexpected number


var myName = "Lebron";

var hits = [];

for ( x = 0; x < text.length; x += 1);
    {
        if(text[x] === "L")
        {
            for (y = x; y < (myName.length + x); y ++ 1);
            {
                hits.push(text[y]);
            }
        }
    }


#2

the syntax error you get is from this bit of code:

y ++ 1

y++ is a shorthand for y += 1, which on his turn is a shorthand for y = y + 1

so y++ is enough.

also, both your for loops, the semi-colon at the very end:

for ( x = 0; x < text.length; x += 1); <- this one

is a very dangerous one, it interrupts the loop, preventing it from running properly, remove the semi-colon (both loops)


#3

Thank you so much, I was able to move on to the next lesson.