The first division to define "i" is always called once and you can define as many variables as you like, this is even better because instead of creating a global variable you can use "let" and make local variables (it has better performance and keeps the code organized)
There is another way to do the for loop:
for(var i=0, k=arr.length; i < k; i++) {}
The first division to define "i" is always called once and you can define as many variables as you like, this is even better because instead of creating a global variable you can use "let" and make local variables (it has better performance and keeps the code organized)
The examples in the article should use let instead of var anyway. Nice one with the "k" in your example.
You’re are correct, I still need to revise it and edit it! I really appreciate the feedback!
I know “let” is the new way to declare variables and “var” was pretty much the old school way.
It's not so much "new" vs. "old" school as they are not quite the same. "var" is basically available everywhere whereas "let" is limited to a scope.
Block scope is best either with let or IIFE