Created
October 20, 2023 22:02
-
-
Save LukeberryPi/216f694db1d4a4bab4053c1a2fb578c5 to your computer and use it in GitHub Desktop.
function to generate a random hexcode
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 generateRandomHexCode() { | |
const validChars = "abcdef0123456789"; | |
let hexcode = "#"; | |
for (let i = 0; i < 6; i++) { | |
const char = validChars[Math.floor(Math.random() * validChars.length)]; | |
hexcode += char; | |
} | |
return hexcode; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment