Current point in string + myName.length Error


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++){

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

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:


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?


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.


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