Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 829 Bytes

README.md

File metadata and controls

24 lines (16 loc) · 829 Bytes

Random Number Generator

A simple random number generator that will allow you to select minimum and maximum values to generate a number between and then generate and display the number once the button is clicked.


document.querySelector('.numberGenerator').addEventListener('click', function() {

  //// Set minimum and maximum numbers
  var minEntry = parseInt(document.querySelector('.minimumNumber').value);
  var maxEntry = parseInt(document.querySelector('.maximumNumber').value);

  //// Create variable with random number from given range
  var randomNumber = Math.floor(Math.random() * (maxEntry - minEntry + 1) + minEntry);

  //// Display randomly generated number
  document.querySelector('.number').textContent = randomNumber;
  
});