5 int for loop


var text = "Hey,how are you\
doinh? My name is Emily?"
var myName = "Emily"
var hits = []

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

I am not sure what is wrong in here.


I think You mixed up the two loops.

The first loop has to loop over length of text where as the second loop should loop over length of myName starting from index it catches the first letter of myName.


This change worked. Thanks!


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