DEV Community

loading...

Discussion on: What the Hex!? (how to generate random hex color codes in javascript)

Collapse
thecodepixi profile image
Emily A. Pixi Author

Yeah someone else pointed this out to me. Math.floor vs Math.round is one of those things I always forget. Also, excellent work on the alt method! Just as a note, with that solution, it is possible you will get hex codes that are less than 6 digits in length, which won't work as color codes. You'll still need a way to check for the length of the code.