DEV Community

Discussion on: Generate and Set Pseudorandom Hexadecimal Background Color Using JavaScript

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited
randomHexColour = ()=>'#'+(~~(Math.random()*(2<<23))).toString(16).padStart(6,0);
Collapse
 
nickfazzpdx profile image
Nicholas Fazzolari • Edited

This is awesome! Now I get to spend this afternoon understanding the code. Thank you.

Collapse
 
stereobooster profile image
stereobooster • Edited
() => `#${Math.floor(Math.random()*(16777215 + 1)).toString(16).padStart(6,"0")}`