Second loop is working but not letting me pass


The error message is "Careful: your second 'for' loop should stop when it reaches its current point in the string
+ myName.length." When the console prints 'hits' hit comes up with the full name - nothing more, nothing less.
No idea what I'm missing in my loop.

var text = "Sometimes Alex wonders what Josh is currently doing"
var myName = "Josh"
var hits = []

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


I believe it has something to do with your second for loop.

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

myname should be myName.


Thanks, that fixed the problem.


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