Your Second "for" Loop >>>>ASSIST


#1

Pleas my code keep going into an endless loop. How can I fix it?

/*jshint multistr:true */

var text = "Anjola Obadiah Joseph Yakubu Nikalus Alexander Joannes"

var myName = "Anjola"

var hits = []

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


#2

you need to push your text variable and all the items your variables is looping through text[j]

hits.push(text[j])


#3

It still goes into an endless loop and crashes my browser.


#4

Oops yea that's dangerous :cold_sweat: Please post your updated code so I can take a look at it again:slight_smile:


#5

Thanks I finally figured it out.


#6

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