Your second "for" loop...error


#1

/*jshint multistr:true */
var text = "Hello! My name is Oliver, \
after spending 5 years on and island i came back to \
save my city.";
var myName = "Oliver";
var hits =[];
for (var i=0; i < text.length; i++){
if (text[i] === 'myName'){
for (var j=i; j < text.length; j++){
hits.push(text[j]);
};
};
};


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


#2

Oops! That loop is gonna run like .... Yes, the error message says what you should be doing.

var text = "Hello, My name is Oliver, \
after spending 5 years on and island i came back to \
save my city.";
var myName = "Oliver";
var hits = [];
for (var i=0; i < text.length; i++)
if (text[i] === "O")
for (var j=i; j<myName.length+i; j++){
hits.push(text[j]);
}

Hope this helps! :smile: