I'm recently watching JavaScript online course, and I built the 'pig-game'. There's input box for set the winning score. I want to improve it if user types the value that is not 'number', then it's value will change automatically to '100' as default. I put if statement there, but I can't solve It's parameter. e.g. if(input === number) doesn't work.
You can check my github (https://github.com/wonkooklee/pig-game) and code is below
//
document.querySelector('.btn-hold').addEventListener('click', function() {
if (gamePlaying) {
scores[activePlayer] += roundScore;
document.getElementById(`score-${activePlayer}`).textContent = scores[activePlayer];
let input = document.getElementById('scoreSet').value;
let winningScore;
if (input === number) { // This is that I'm dealing with
winningScore = input;
} else {
document.getElementById('scoreSet').value = '100';
}
if (scores[activePlayer] >= winningScore) {
document.getElementById(`name-${activePlayer}`).textContent = 'WINNER!';
document.querySelector(`.player-${activePlayer}-panel`).classList.add('winner');
document.querySelector(`.player-${activePlayer}-panel`).classList.remove('active');
diceDOM.style.display = 'none';
gamePlaying = false;
} else {
nextPlayer();
}
}
});