index.html:673 Uncaught TypeError: Cannot set property 'textContent' of null at showResult (index.html:673) code example

Example: index.html:674 Uncaught TypeError: Cannot set property 'textContent' of null at showResult (index.html:674)

function showResult(winner){
   let message ,messageColor;

   if(winner === YOU){
    message = 'You won!';
    messageColor = 'green';
    winSound.play();


   }else if (winner === DEALER){
     message = 'You lost!';
     messageColor = 'red';
     lossSound.play()


   }else {
    message = 'you drew';
    messageColor = 'black';


   }
   document.querySelector('#blackjack-result').textContent = message;
   document.querySelector('#blackjack-result').style.color = messageColor;
 }

Tags:

Misc Example