Your second "for" loop


Hi, could you help me to find a solution.
I really get stuck with this error. It should be okay, but it shows 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.

/*jshint multistr:true */
var text = "Who are you";
var myName = "Kingking";
var hits = [];

for(var i = 0; i <= text.length; i++)
if(text[i] === "K")

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




Try it including the name you are looking for
by using the text

var text = "Kingking Who are you Kingking";


Thank you so much! it worked.
But, I don't know why my text didn't work, and your text did.


How many hits would you have with your text with

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


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