Generate a random hexadecimal colour code in JavaScript
This file contains 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