Not pushing values to "hits" array?


I had some trouble with the second FOR loop, and corrected it, but now I'm getting the message:

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.

I've browsed similar questions looking for an answer to this, but I'm still at a loss with where to go from here. Any help would be greatly appreciated.

/*jshint multistr:true */
var text = "Some text with my name, Chris";
var myName = "Chris";
var hits = [];

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


text[i] === myName.substring(0)

You just have to compare with first letter of your name.

substring gives part of string..

when you do this..

It means it will give you string from 0 to end index. aka ("Ryan")


Right, that fixed it. Thanks!


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