Skip to content

Instantly share code, notes, and snippets.

@gotofritz
Last active September 8, 2016 06:37
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 gotofritz/5329812 to your computer and use it in GitHub Desktop.
Save gotofritz/5329812 to your computer and use it in GitHub Desktop.
random color
//random color
//from: http://www.mrspeaker.net/2013/03/08/random-hex-colour/
//16777216 = 1 << 24
// ES5
function random_color(){
return '#'+ ( '00000' + ( Math.random() * 16777216 | 0 ).toString( 16 ) ).slice( -6 );
}
// ES6
let random = () => `#${('000000' + (Math.random() * 16777216 | 0).toString(16)).slice(-6)}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment