Home javascript Learn JavaScript and when starting the code, the tab gives an Out...

Learn JavaScript and when starting the code, the tab gives an Out of Memory error, but the memory is enough




code is just 20 lines and when starting it gives an error about the shortage of memory, I have not previously observed this 4GB of RAM, I apply a photo. And there is one more question if someone understood the code, you can explain how the first function (function) may be related to Var Years? I did not understand this moment, the video explains this but unfortunately I did not fully understand it. Thanks

Answer 1

Do you have an error in the code

for (var i = 0; 1 & lt; arr.length; i ++)

Change please the termination condition correctly

for (var i = 0; i & lt; arr.length; i ++)

Otherwise there is an infinite cycle with a constant addition to an array of the


On the second issue, your function is not related to this array, only by passing an array in the parameter you can link them ideally, and your array is declared globally and essentially visible for all your functions.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions