Home > Back-end >  How can I compare a number to find out whether it is higher than another number?
How can I compare a number to find out whether it is higher than another number?

Time:12-17

I have the following code:

// CODE RELATED TO THE INPUT FIELD 
document.querySelector('.check').addEventListener('click', function() {
  const guess = Number(document.querySelector('.guess').value);
  console.log(guess, typeof guess)
  const randomNumber = parseInt(Math.random() * 20);
  console.log(randomNumber);
  /* document.querySelector('.message').textContent = ' nber!' */
  if (!guess) {
    document.querySelector('.message').textContent = 'No number in the field!'
  } else if (guess === randomNumber) {
    document.querySelector('.message').textContent = 'Correct!!            
  • Related