programming-examples/js/Math/Create random background color.js

11 lines
348 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function random_bg_color() {
var x = Math.floor(Math.random() * 256);
var y = Math.floor(Math.random() * 256);
var z = Math.floor(Math.random() * 256);
var bgColor = "rgb(" + x + "," + y + "," + z + ")";
console.log(bgColor);
document.body.style.background = bgColor;
}
random_bg_color();