-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
31 lines (22 loc) · 719 Bytes
/
main.js
File metadata and controls
31 lines (22 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// let bgColor = ["red", "blue", "green", "yellow"];
// let bgColor = Math.floor(Math.random() * 256) + 64;
function randomColor(){
let red = Math.floor(Math.random() * 192) + 64;
let green = Math.floor(Math.random() * 192) + 64;
let blue = Math.floor(Math.random() * 192) + 64;
return `rgb(${red}, ${green}, ${blue})`;
}
// let index = 0;
// function bg(){
// if(index == bgColor.length){
// index = 0;
// }
// document.getElementById("bgchange").style.backgroundColor = bgColor[index++];
// };
function bg(){
let bgColor = randomColor();
document.getElementById("bgchange").style.backgroundColor = bgColor;
};
function autoChange(){
setInterval(bg, 500);
}