Skip to content

Instantly share code, notes, and snippets.

@codergautam
Last active October 24, 2021 15:38
Show Gist options
  • Save codergautam/81ca397fc18f5b2386ea7732b9b722e1 to your computer and use it in GitHub Desktop.
Save codergautam/81ca397fc18f5b2386ea7732b9b722e1 to your computer and use it in GitHub Desktop.
A simple function to get a random integer from a range in JavaScript.
const getRandomInt = (min, max) => min + Math.floor(Math.random() * (max - min + 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment