The explanation for this came up a few weeks ago, and the conversation led to a ticket being submitted, and the course revised. I’ll have to dig around for that topic.
id="door1", causes the browser to create a global variable by that name. What gets assigned I wouldn’t know. I suspect it to be a nodelist, which is why we could access it even without caching the nodes.
door1 indeed had a
In the meantime, the CXP team accepted the recommendation to correct the course so that we are not misusing globals as they are rather vulnerable to other scripts using the same variable names.
JS occupies a single namespace which means collisions with other script libraries is possible in the global scope. By caching our nodes and not depending upon a global, we protect the objects we’ve cached and are less vulnerable to collisions.
ID is far more focused than we knew, apparently