Skip to content

Instantly share code, notes, and snippets.

@brookjordan
Last active March 16, 2023 11:51
Functions to get random colours string in hex or RGB
const byteNumber = () => Math.random() * 2 ** 8 >> 0;
export const randomHex = () =>
'#' + (2 ** (2 ** 3 * 3) * Math.random() >> 0).toString(16).padStart(6,'0')
;
export const randomRGB = () =>
`rgb(${[byteNumber(),byteNumber(),byteNumber()]})`
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment