var
declares a global variable while
let
declares a variable to a limited scope. In this case, the scope of the variable is inside the loop. Outside the loop,
i doesn't exist.
If you leave this as
var
, the scope of the variable is the end constfuncs() function.
See
this[
^] for more information.