#5: What is my mistake and how to fix it


Here is part of my code:

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

I've looked for an answer to my problem on the forums, but it seems I can't find a solution to the problem. I think the problem is that I did the push method wrong? I don't completely understand why I'd be pushing a variable representing a number to the hits array.

Please tell me what I did wrong,no spoilers, and how to fix it. If you need/want to see more of the code, tell me.


im not a pro yet and still learning. But line 3 what does J = to? it says j=; should be = to i?


Hi first here

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

Like @cssplayer42079 said you should put j = i An d then here


You should put j less than i+myName.length like that

j < (i+myName.length)

So this part should be like that

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


you haven't declared j "(j=;" should be more like "(var j=1;"
then you have said while j equals i+myName.length, it will only equal myName.length+i once when you have completed a match so you want it to say j < myName.length then you need to cycle through the characters by using text[i+j]===myName[j]

hope that helps i've got mine to work but it's complaining even though it works. lol


Thanks guys. I swear I had fixed that semicolon.... :neutral_face:
I can't believe i forgot to declare j as a variable! I guess I haven't fully come back from my vacation from Codecademy.