Skip to content

Instantly share code, notes, and snippets.

@steveshead
Last active January 30, 2021 05:08
Show Gist options
  • Save steveshead/22fcb0cc4652f5722242db0a3deb7005 to your computer and use it in GitHub Desktop.
Save steveshead/22fcb0cc4652f5722242db0a3deb7005 to your computer and use it in GitHub Desktop.
[Javascript Random Number Generator] - create a constant that takes two number inputs to generate a random number between those two number
const randomInt = (min, max) => Math.floor(Math.random() * (max - min) + 1) + min;
console.log(randomInt(10, 20));
// Used floor instead of trunc so negative numbers can be used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment