I don't understand what's wrong!


#1


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

Oops, try again. 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 = ("boom", "Natalia", "flowers", "sock");
var myName = "Natalia";
var hits = [ ];

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


#2

HI this line

var text = ("boom", "Natalia", "flowers", "sock");

you should put your name in a string like that

var text = "Hi, My name is Natalia..";

and not inside a tuple


#3

Hello!

The program didn't mind the code to be like that but when I correct it to your way it still shows an error: "Oops, try again. There was a problem with your syntax."


#4

can you post your new code?


#5

var text = "boom", "Natalia", "flowers", "sock";
var myName = "Natalia";
var hits = [ ];

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


#6

change that

var text = "boom", "Natalia", "flowers", "sock";

to

var text = "boom, Natalia, flowers, sock";