Search for text for you name second 'for" loop


#1


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

https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#


/*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++){
        hits.push('myName')
        }
    }
}


#2

this:

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


#3

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