forked from bajajvinamr/HacktoberFest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (36 loc) · 1.24 KB
/
index.html
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
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Counter Project</title>
</head>
<body>
<!-- <button onclick="Increment()"> Increment </button>
<button onclick="Decrement()"> Decrement </button>
<button onclick="Reset()"> Reset </button> -->
<button onclick="change()">Change</button>
<script>
// var num = document.querySelector('#number');
// var counter = 0
// function Increment(){
// counter++;
// num.innerText = counter;
// }
// function Decrement(){
// counter--;
// num.innerText = counter;
// }
// function Reset(){
// counter = 0;
// num.innerText = counter;
// }
const colors = ['red', 'blue', 'green', 'pink', 'yellow', 'orange', 'lightblue', 'lightgreen', 'grey'];
function change(){
const colorIndex = parseInt(Math.random() * colors.length);
console.log(colorIndex);
document.body.style.backgroundColor= colors[colorIndex];
}
</script>
</body>
</html>