Current point in string + myName.length Error


#1

having a problem with my code can someone give me a hand?

var text = "Hello people!";
var myName = "Williams";
var hits = [];

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

I keep getting and error. " Oops, try again. Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length "


Stuck on Your second "for" loop
#2

This needs to be checked in the part where you have written j < my name.length.

So the current point in the string will be stored in the i variable, try to figure out how to fit the check :slight_smile:


#3

I was wondering when you said that I need to "check the [ j < myName.length ] figure a way to check it". I was trying this[ j < Williams.length] but I know that can't be it. was wonder can you give me a another hint?


#4

The check should be:

j < (myName.length + i)

That way you are adding the i from the first loop to the whole length of the name.


#5


still getting the same error not pushing the syntax what did I miss?