Am I doing it wrong?


I used another initialisation and condition

This is how I thought it could be done

var text="I am a code whose name is Thayyeb it means good or Thayyeb";
var myName="Thayyeb";
var hits =[];
for (var i=0;i<text.length;i++){
        for(var j=0;j<myName.length;j++){

I can't finish the challenge
Can anyone could enlighten me on what is wrong?


lets see what the actual output is for your code:

[ 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' ]

that doesn't look right. The second loop should loop over your name in text string

once the first letter of your name is found in text string (i, thanks to your if condition) the second for loop should start at this index, then loop till the end of your name in text string, how could we achieve this?

the hint in the exercise:

Your loop should stop when it hits the value of the first iterator (say, i) plus the length of your myName variable

is pretty good


Thank you.
I got it a bit mixed up and confused.