-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.exercise.js
40 lines (29 loc) · 1.04 KB
/
script.exercise.js
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
32
33
34
35
36
37
38
39
40
// console.log("hello world")
// console.log(document.querySelectorAll(".box"))
// document.querySelectorAll(".box1").forEach(e=>{
// e.style.backgroundColor = "red"
// })
// document.querySelectorAll(".box2").forEach(e=>{
// e.style.backgroundColor = "blue"
// })
// document.querySelectorAll(".box3").forEach(e=>{
// e.style.backgroundColor = "green"
// })
// document.querySelectorAll(".box4").forEach(e=>{
// e.style.backgroundColor = "yellow"
// })
// document.querySelectorAll(".box5").forEach(e=>{
// e.style.backgroundColor = "grey"
// })
console.log("script.js initializing")
let boxes = documnet.querySelector(".container").children
function getRandomColor(){
let val1 = Math.ceil(0 + Math.random()* 255);
let val2 = Math.ceil(0 + Math.random()* 255);
let val3 = Math.ceil(0 + Math.random()* 255);
return `rgb(${val1}, ${val2}, ${val3})`
}
Array.from(boxes).forEach(e=>{
e.style.backgroundColor = getRandomColor()
e.style.color = getRandomColor()
})