JSFiddle - React, Tailwind, and code Playground
by It Muravshchyk
JavaScript
const COLOR = (function() {
return {
red : function() {
return Math.floor(180 + Math.random() * (255 + 1 - 180));
},
green : function() {
return Math.floor(150 + Math.random() * (255 + 1 - 150));
},
blue : function() {
return Math.floor(Math.random() * 0);
}
};
})();
function getColor(){
return "rgb(" + COLOR.red() + ", " + COLOR.green() + ", " + COLOR.blue() + ")";
}
var html = document.getElementsByTagName("html")[0];
html.addEventListener("click", function() {
html.style.backgroundColor = getColor();
});