Oops, try again. 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


Can someone help me out?  I'm not sure where i went wrong.
var text = "Hello how are you\
? My name is ken";
var myName = "Ken";
var hits =[];

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


In your text, ken appears with a lowercase k. In the myName variable, you have uppercase K. This is why the 2nd for loop never executes.


Thanks a lot..I've sat on this so long..


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