Generate random hex code

Last update in 8/2019

This will be short and not really practical but fun article.

Have you ever wondered how to generate random hex code?

Probably not, but here it is.

'#' + Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, '0');

One-liner, short and sweet.

Now you can use it to create fun web pages like demo I've created for this article.

Resources #