diff --git a/1-color-flipper/app.js b/1-color-flipper/app.js index 901729f..7109967 100644 --- a/1-color-flipper/app.js +++ b/1-color-flipper/app.js @@ -1 +1,14 @@ const colors = ["green", "red", "rgba(133,122,200)", "#f15025"]; + +const btn = document.getElementById('btn'); +const color = document.querySelector(".color"); + +btn.addEventListener('click', function () { + const randomNumber = getRandomNumber(); + document.body.style.backgroundColor = colors[randomNumber]; + color.textContent = colors[randomNumber]; +}) + +function getRandomNumber() { + return Math.floor(Math.random()*4); +} \ No newline at end of file diff --git a/1-color-flipper/index.html b/1-color-flipper/index.html index 2aff836..328d616 100644 --- a/1-color-flipper/index.html +++ b/1-color-flipper/index.html @@ -9,7 +9,22 @@
-