Quantcast
Channel: Javascript function runs indefinitely when inside for-loop - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Dragoş Paul Marinescu for Javascript function runs indefinitely when inside for-loop

$
0
0

You have a second for loop inside your function, which infinitely increases i. Replace i with j or any other variable name in any of the two for loops and it will work as expected.

You could use the same variable name, i if you declare them locally inside the for loop using the let keyword, which declares variables only in the current block.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>