let is intended for blocks that until now haven’t had their own scope. Control flow objects fit that bill.
do..while loops, foremost, but switches and if statements have code blocks, too, though one wonders why any scope would be needed in them.
Until we’re told
var is deprecated, it makes sense to use it, or
const in global scope.
var also applies to function scope so doesn’t need replacement in that context.
for (let i = 0; ....
i from leaking out of the loop body.
Now I don’t know what is being written elsewhere about these keywords. They are all declarative, and all inherent their parent scope (still to be tested and demonstrated). They all have a specific purpose.
const => immutable
var => declares position in scope chain
let => block scope in control flow objects
It makes perfect sense to declare function expressions as constants. That way they cannot be overwritten. But the same applies to objects that we do not want to change. The path URLs make sense, but so too do the cached element nodes.
As for the globals, they can all be
var. We would not write,
const currentlyPlaying = true;
since we need to toggle that value, and the above will not allow that. It’s constant. If we look at the
startRound function all the globals get defined by it, so all we really need is to declare them all in the initialization phase.
var numClosedDoors, openDoor1, openDoor2, openDoor3, currentlyPlaying;