I am having an issue with updating text content, if I select the element with document.querySelector() then it works but if I store the element in an object then I can't seem to update it.
Example:
let player1 = {
totalScore: 0,
currentScore: 0,
totalScoreBox: document.querySelector('#score--0').textContent,
currentScoreBox: document.querySelector('#current--0').textContent
}
const updatePlayerScore = (player, value) => {
player.totalScore += value;
player.currentScore += value;
player.currentScoreBox = parseFloat(player.currentScore); //Doesn't work
document.querySelector('#current--0').textContent = parseFloat(player.currentScore); //Works
}
https://jsfiddle.net/Copopops/rsuc7m4g/1/
Thanks in advance.