function genHexColor() {
return '#'+(Math.random()*(1<<24)|0).toString(16).concat('000000').slice(0,6);
}
Call the genHexColor() function to obtain a random color in Hex format.
///
Latest version: Prevents the function from returning hex strings shorter than 6 characters.
///
Latest version: Prevents the function from returning hex strings shorter than 6 characters.
5 Responses
`'#' + (Math.random() * (1<<24) | 0).toString(16)`
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.