Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Created February 27, 2021 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidWells/cbba531820441f9bd1072dc972583386 to your computer and use it in GitHub Desktop.
Save DavidWells/cbba531820441f9bd1072dc972583386 to your computer and use it in GitHub Desktop.
Random true / false in JS
function randomFromRange(start, end) {
return Math.round(Math.random() * (end - start) + start);
}
function randomTrueFalse() {
return randomFromRange(0, 1) ? true : false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment