Your second for loop #5


Can anyone help? It says it's not pushing values to the hits array.

var text = "Who knows what I'm supposed to write";

var myName = "Dan";

var hits = [];

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




I know the text is supposed to say 'D' instead of 'E'. Forgot to change that for the sake of this question. But even then, it's still saying the same error message.


your name is not present in the string stored in text variable, so i can't be found


Declare and set the following three variables:

01.var text, and make it a string containing some text. Place your name in there a couple of times!

For ex. var text= " "Hey, Dan how are you doing My name is Dan";


also log the hits array (console.log(hits) ) to the console under your existing code (and outside all your loops!)


Link the page where you're stuck!


If you're at first lesson of exercise then you've to follow along.
You'll be adding different parts of code in next lessons.

If you're at last part of lesson as you can see the last part is log it! and victory

Then you need to go through the exercise and read instructions, You're missing

I hope it helps!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.