5. Your second "for" loop


#1


5. Your second "for" loop


I have no idea what to do and I am very confused. The page also becomes unresponsive. Please help.


/*jshint multistr:true */
var text = "bla bla bla bla bla bla Michael bla bla bla bla Michael"
var myName = "Michael"
var hits = ["Michael"];

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


#2

Your page becoming unresponsive on running your code suggests that you have an infinite loop, you would need to look closer at your conditions and anything that affects them. You may also want to observe rather than speculate, print out values that your conditions rely on to see whether they change the way you expect them to.


#3

both for loops are using the variable i


#4

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