Skip to content

Instantly share code, notes, and snippets.

@jzevin
Last active March 15, 2022 17:54
Show Gist options
  • Save jzevin/4f756cdeb5ad1b4dd642c2d0e06ef207 to your computer and use it in GitHub Desktop.
Save jzevin/4f756cdeb5ad1b4dd642c2d0e06ef207 to your computer and use it in GitHub Desktop.
rnd
const log = console.log.bind(console);
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
const rnd = {
color: () => `#${Math.floor(Math.random()*16777215).toString(16)}`,
dec: (min=0.0,max=1.0) => Math.random() * (max - min) + min,
int: (min=0,max=1) => Math.floor(Math.random() * (max - min + 1) + min),
pick: (array) => array[Math.floor(Math.random() * array.length)]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment