Created
October 10, 2017 22:44
-
-
Save steven-work-space/3f99ba5cdd0e6fc9cf697d8d8c01b2a2 to your computer and use it in GitHub Desktop.
Getting a random color in Hex format
This file contains hidden or 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 getRandomColor() { | |
myColors = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"); | |
randomColor = "#"; | |
for(let i = 0; i < 6; i++) { | |
randomColor += myColors[Math.floor(Math.random() * myColors.length)]; | |
} | |
return randomColor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment