TIL how to generate a random color using JS
POSTED ON:
TAGS: javascript
Need a color but can't figure out what?
Randomize it!
(Math.random()*0xFFFFFF<<0).toString(16)
This will give you a random color hex value.
So you can do something like this:
const myColor = '#'+(Math.random()*0xFFFFFF<<0).toString(16);
body.style.background = myColor;
Via https://codepen.io/ixahmedxi/pen/VpLeEw
Related TILs
Tagged: javascript