diff --git a/js/script.js b/js/script.js index 803c165..4a8d085 100644 --- a/js/script.js +++ b/js/script.js @@ -4,9 +4,8 @@ const body = document.querySelector('body') const colors = ['red', 'green', 'blue', 'yellow', 'pink', 'purple'] body.style.backgroundColor = 'violet' -button.addEventListener('click', changeBackground) - -function changeBackground(){ -const colorIndex= parseInt(Math.random()*colors.length) +button.addEventListener('click', () => { +const colorIndex = Math.floor((Math.random()*colors.length)) body.style.backgroundColor = colors[colorIndex] } +)