Skip to content

Instantly share code, notes, and snippets.

@m4n50n
Created December 15, 2021 18:39
Show Gist options
  • Save m4n50n/60940b21084fd282decac6ae98508119 to your computer and use it in GitHub Desktop.
Save m4n50n/60940b21084fd282decac6ae98508119 to your computer and use it in GitHub Desktop.
Math.random.js
// Returns a random integer from 0 to 9:
Math.floor(Math.random() * 10);
// Returns a random integer from 0 to 10:
Math.floor(Math.random() * 11);
// Returns a random integer from 0 to 99:
Math.floor(Math.random() * 100);
// Returns a random integer from 0 to 100:
Math.floor(Math.random() * 101);
// Returns a random integer from 1 to 10:
Math.floor(Math.random() * 10) + 1;
// Returns a random integer from 1 to 100:
Math.floor(Math.random() * 100) + 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment