Skip to content

Commit a5a68ef

Browse files
author
mk1121
committed
successfully complete project-1 past part
1 parent 6d28e3b commit a5a68ef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

01-color-flipper/setup/app.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
const colors = ["green", "red", "rgba(133,122,200)", "#f15025"];
2+
const btn = document.getElementById("btn");
3+
const color = document.querySelector(".color");
4+
5+
btn.addEventListener("click", function(){
6+
const randomNumber = colors[getRandomNumber()];
7+
document.body.style.backgroundColor = randomNumber;
8+
color.textContent = randomNumber;
9+
});
10+
function getRandomNumber(){
11+
return Math.floor(Math.random() * colors.length);
12+
};

0 commit comments

Comments
 (0)