I have created a function in order to tidy up some code but the function is not returning the value that I want. I am trying to remove 1 from the current value of 'lives' which is 20 but when calling the function its returning the value 20.
This is the function that I have created:
const removeLives = function(lives) {
return lives--;
}
and I'm calling it here:
// if guess is too high
} else if (userNumber > randomNumber) {
document.querySelector('.message').textContent = 'Too high! ☝️';
removeLives(lives);
document.querySelector('.lives').textContent = `Lives: ${lives}`;
This is the code I had previously and it works fine:
// if guess is too high
} else if (userNumber > randomNumber) {
document.querySelector('.message').textContent = 'Too high! ☝️';
lives--;
document.querySelector('.lives').textContent = `Lives: ${lives}`;
I'm a beginner to this stuff and any help would be appreciated!