Help needed in for Loop 2


#1

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

Hi all, I got a infinity loop from this code ,


Replace this line with your code. 
var text=("Hey, My name is Darius \
, where Darius is also a League hero")

var myName=("Darius")

var hits=[]

for (var i=0;i<text.length;i++){
    if (text[i]==='D'){
       for(var j=i;j<(i+myName.length);i++){
            hits.push(text[j])
            }
            
      }
}


#2

in the second for loop:

i++

you increase i, why? you use j to loop over your name found in text, so it would make sense to increase j, not i


#3

Oh right! I missed that , Thanks!


#4