Eroor message: Potential infinite loop detected on line 4. Tests may fail if this is not changed

Tell us what’s happening:

Your code so far


// Setup
var myArray = [];
var i = 0;
while(i < 6)
myArray.push(i);
i++;

// Only change code below this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

compare the code you posted to this code found on the challenge page …

var ourArray = [];
var i = 0;
while(i < 5) {
  ourArray.push(i);
  i++;
}

2 Likes

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

It is not a potential infinite loop, javascript is being kind (and maybe assuming you have information it lacks. Currently, your one-line while statement is absolutely infinite. It will never reach an escape state. i never increments.

1 Like