Created
August 5, 2018 13:15
-
-
Save TravisMullen/3e19f15b8e7c17b954e55c1302bf462c to your computer and use it in GitHub Desktop.
Generate a random hex value.
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
const hexGenerator = function(length = 16) { | |
let text = ""; | |
const possible = "ABCDEFabcdef0123456789"; | |
for(let i = 0; i < length; i++) { | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
} | |
return text; | |
} | |
// convert to random with parseInt(`0x${hexGenerator()}`, 16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment