Infinite loop crashing browser

Tell us what’s happening:
Describe your issue in detail here.
This code is completely wrong, I’ve corrected it since but I thought it might be worth mentioning that the incorrect code provided crashes the browser, I don’t know if it’s worth reporting it. I know it’s because I’ve basically created an infinite loop.

It only started hanging and freezing after the console.log() reached the end of the display line i.e.
[6,7,8,9,10,11,12,13
14,
15,
16,
17,
18,
19]
I think this is the issue, instead of using all of the space on the next line, it started creating a new line for each console.log after the first line reached its limit.
Example

Not really a big issue by any means but I tested it in both Opera GX and Chrome with the same result and again I don’t really know if there’s anything that can really be done about it but I thought I’d post it just incase there was a way in the background that the site could implement some kind of infinite loop detection (in terms of time/value to implement it’s probably not). I remember while I was doing Rust in university, there was a very specific way of doing it but whether it’s possible with web languages.

  **Your code so far**
// Setup
const myArray = [];

// Only change code below this line
let i = 6;

while (i >= 6) {
myArray.push(i);
i++
console.log(myArray)
}
  **Your browser information:**

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

Challenge: Basic JavaScript - Iterate with JavaScript While Loops

Link to the challenge:

I correctly get this

after a certain amount of time the loop is stopped correctly

make sure you don’t have browser extensions that are interfering and that your browser is updated to latest version

1 Like

Apologies! I have a few dev tool extensions, maybe they were eating resources trying to digest what was happening on the page, thank you for the response :slight_smile: