Created
January 7, 2020 15:50
-
-
Save lukem512/327e424da8a1c8b573479dee6b7bec2a to your computer and use it in GitHub Desktop.
Generate a random hexadecimal colour code in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to generate a 24-bit (non-alpha) colour (color, for US English speakers) | |
function makeRandomColour() { | |
const MAX_INT24 = 16777215; | |
return '#' + Math.round(Math.random() * MAX_INT24).toString(16); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment