Skip to content

Instantly share code, notes, and snippets.

@djleonskennedy
Last active April 18, 2017 08:11
Show Gist options
  • Save djleonskennedy/9bcb97d8bb3c457abcfe241ce9c2bcbc to your computer and use it in GitHub Desktop.
Save djleonskennedy/9bcb97d8bb3c457abcfe241ce9c2bcbc to your computer and use it in GitHub Desktop.
generates random HEX color
// TS
const randomColorGenerator = (): string =>
`#${(Math.random().toString(16) + '0000000').slice(2, 8)}`;
// ES6
const randomColorGenerator = () =>
`#${(Math.random().toString(16) + '0000000').slice(2, 8)}`;
// ES5
var randomColorGenerator = function () {
return "#" + (Math.random().toString(16) + '0000000').slice(2, 8);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment