Search for text for you name second 'for" loop


I'm not sure what i have done wrong please help

/*jshint multistr:true */
 var text = "hey how are doing? My name is milly.";
 var myName = "michael";
 var hits = [];
for(var i = 0; i < text.length; i++){
    if(text[i] === 'H'){
        for(var j = i; i+ myName.length; i++){



i+ myName.length

is not a condition? you use j to loop over your name, which goes from i till i + myName.length, does that help you to make the condition?

also, j contains the indexes, so text[j] contains the letters of your name, which you need to push into the hits array


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