Created
June 1, 2018 12:22
-
-
Save jcunanan05/26ce5e4ddaaed865744a16759855b1bd to your computer and use it in GitHub Desktop.
Javascript code for spouting rgb colors
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 randomNumber(maxNum) { | |
return Math.floor((maxNum * Math.random()) + 1); | |
} | |
function randomRgb() { | |
var r = randomNumber(256), | |
g = randomNumber(256), | |
b = randomNumber(256); | |
return 'rgb(' + | |
r + ', ' + | |
g + ', ' + | |
b + | |
')'; | |
} | |
function changeBackgroundColor(element) { | |
element.style.backgroundColor = randomRgb(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment