Help Please?


#1
<code>
/*jshint multistr:true */

var  text = 'Hi,I am JOY.Joy is a programmer.';
var myName = "JOY";
var hits = [];
for (var i = 0; i < text.length; i++){
        if (text[i] === myName[0]) {`
            for(var j = i; j < (myName + i); j++){
                hits.push(text[j]);
            }
    }
}


#2

Hi this line

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

myName should be myName.length


#3

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