Why dose this returen 3?


#1

I dont understand why its returing the number of times my name comes up or why it let me pass because of it . here is the code can anyone help me.

/*jshint multistr:true */
var text = "trip trap look at that! here goes my name,Amber\ thats my name so hear it again Amber do you want to hear it again ? \ Amber";

var myName ="Amber";
var hits = [];

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

and then it gives and answer of 3

#2

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

Delete the semi-colon " ; " at the end of your second for loop.


#3

thanks I tried it but now it shows 15 instead. lol thats the correct number of letters I know but why no letters themselves ?


#4

The next lesson will have you print the letters.


#5

actually I worked it out but thanks so much for helping your awesome :smile: