From 27ca37744710f35020c276341acfc2dc4391b224 Mon Sep 17 00:00:00 2001 From: MukulsinghRajpurohit <88364925+MukulsinghRajpurohit@users.noreply.github.com> Date: Thu, 16 Dec 2021 22:32:13 +0530 Subject: [PATCH] Replace hard color to there CSS HEX values change color to there HEX values and all semicolons at end of every statement . --- js/script.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/script.js b/js/script.js index 803c165..77b7485 100644 --- a/js/script.js +++ b/js/script.js @@ -1,12 +1,12 @@ //Choose a random color -const button = document.querySelector('button') -const body = document.querySelector('body') -const colors = ['red', 'green', 'blue', 'yellow', 'pink', 'purple'] +const button = document.querySelector('button'); +const body = document.querySelector('body'); +const colors = ['#ff0000', '#3cb371', '#0000ff', '#ffa500', '#ff6375', '#6a5acd']; -body.style.backgroundColor = 'violet' -button.addEventListener('click', changeBackground) +body.style.backgroundColor = 'violet'; +button.addEventListener('click', changeBackground); function changeBackground(){ -const colorIndex= parseInt(Math.random()*colors.length) -body.style.backgroundColor = colors[colorIndex] +const colorIndex= parseInt(Math.random()*colors.length); +body.style.backgroundColor = colors[colorIndex]; }