Why would this be infinite loop?

Hi all
I have already looked up the correct answer to this test but I am slightly confused as to why this code would be an infinite loop. Why wouldn’t the loop just count down from 5 to 0. Is it saying that it would it count into negative numbers and not stop at 0?

  **Your code so far**

// Setup
var myArray = [];

// Only change code below this line
var i=5;
while (i<=5) {

  **Your browser information:**

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

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

1 Like


Yes it would count into negative numbers, looping forever.

1 Like

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