Do the counters of the for loop work outside of it?
Loop counter variables only live in the loop.Hanna Davies
Well damn, this is the basics. Explained in any tutorial.
Let and const are block-scoped. So, in this case, each cycle will have its own variable.
In the case of var, the variable will remain available after the loop ends. Its value will be equal to the last iteration of the loop.
If a new loop follows, then it doesn't matter if the variable was previously declared. It is still initialized with the starting value (
var i = 0;).Anonymous
Is it possible to make a counter i in each of them
To place the code, please use CodePen or similar tool. Thanks you!