11. Review - Why am I getting an infinite loop?


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-ASGIv/2/4?curriculum_id=506324b3a7dffd00020bf661

My code is creating an infinite loop. I reviewed it, but can't find the problem. Help is appreciated!


var array007 = ["Penn", "Michelle", "Kimberly", "Amber"]

for(i=0; i< i + array007.length; i++) {
    console.log("Slim Shady is here with his homie" + array007[i])
};
    
var jimmyJohns = true

var dominos = function() {
    while (jimmyJohns) {
        console.log("Dominos beats Jimmy Johns.")
        jimmyJohns = false
    };
};

dominos()

var pizzaHut = false

do {
    console.log("array007.length")
} while (pizzaHut);


#2

This is the thing that stops your loop:

i < i + array007.length

When do you expect that it will be false?


#3

Hey Albion, thanks for replying to my question.

You're right, i < array007.length for this to work.

Thanks!


#4

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