javascript how to random set rgb colors code example
Example 1: javascript random rgb
var r = () => Math.random() * 256 >> 0;
var color = `rgb(${r()}, ${r()}, ${r()})`;
Example 2: random rgba color javascript except black
function random_bg_color() {
var x = Math.floor(Math.random() * 256);
var y = 100+ Math.floor(Math.random() * 256);
var z = 50+ Math.floor(Math.random() * 256);
var bgColor = "rgb(" + x + "," + y + "," + z + ")";
console.log(bgColor);
document.body.style.background = bgColor;
}
random_bg_color();