For example if you have an input and you then select it like so:
var input = document.querySelector(‘input’);
var finalScore = 7;
var finalScoreDisplay = document.querySelector(‘#finalScoreDisplay’);
Then you do:
var userFinalScore = input.value;
var userFinalNumber = Number(userFinalScore);
And you also have:
finalScore = userFinalNumber;
finalScoreDisplay.textContent = finalScore;
Weird things start happening when you start putting DOM (Document Object Model) representations of HTML elements, while accessing their properties, and then trying to put that into variables. They don’t seem to work anymore. It’s as if the value gets overwritten, AND/OR the variable’s not actually getting assigned the value. Or at least the value you intended to assign it.
This would be because the variable is getting assigned a reference to the location of the object, as a value. As opposed to the variable getting assigned the value of the object’s property itself.
By the way if you see something else going on here I might like to know about, let me know! Comment, email, smoke signal, it’s all fine. I’d appreciate it.
And now, back to coding.
Love & Peace,