I Can't See What I Did Wrong


#1

Hey, I tried looking up what i did wrong, but i can't seem to find anything wrong.

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

#2

Hi its missing the open { of the first for loop

for (var i = 0; i < text.length; i++) #here add one {
    if (text[i] === "M") {
        for (var j = i; j < (i + myName.length); j++) {
            hits.push(text[j]);
        }
    }
};

#3

I had tried that and it still doesn't let me pass.


#4

Hi can you post all your new code and the error you get?


#5

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

Oops, try again. Did you remember to log the result of your search to the console?

I don't understand what I have to do at this point.


#6

on what lesson are you ?

here you put 1 instead of i

for( var j = i; j < (1 + myName.length); j++)

shoud be like that

for( var j = i; j < (i + myName.length); j++)

#7

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

Oops, try again. Did you remember to log the result of your search to the console?

  1. Log it.

#8

instead of 1. I mean 6. Log it not 1.


#9

do have the

var text  =..

var myName =...

var hits = ...

on top of your code?


#11

Hi I just ran it and it work


#12

strange. Copy and Paste the code there to here so i can make sure there is nothing wrong.


#13

I figured it out. Finally!


#14

thank you for your help!