My second 'for' loop!


#1

Your second 'for' loop should stop when it reaches its current point in the string + myName.length:

var text = "Hey, how are u? \
My name is Luis, do u know me? \
Everybody calls me Luis, so \
i'm sure u know my name 'Luis' \
Nice to meet you, my friend \
Next time call me Luis, Ok?";

var myName = "Luis";

var hits = [];

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


#2

Hi here

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

This part j < myName.length add i to your myName.length like that

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

#3

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:

for( var j = i; i < i + myName.length; j++) {
myNames.push("Lilian");
}
}
}


#4

Hi you should push it inside hits so Its should be like that

hits.push(text[j])

Inside your if condition it should be like that

if( text[i] === "L")

It should be equal to the first letter of your name.


#5

THANKS!!!!:kissing_closed_eyes: