From 31169ac9247a764bb4cffb8519202599f710cf84 Mon Sep 17 00:00:00 2001 From: gaizkamg <57919401+gaizkamg@users.noreply.github.com> Date: Wed, 19 Mar 2025 22:07:04 +0100 Subject: [PATCH] Update script.js I fixed the array length --- Change_Color_Background/js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Change_Color_Background/js/script.js b/Change_Color_Background/js/script.js index ea46b78..750a2e7 100644 --- a/Change_Color_Background/js/script.js +++ b/Change_Color_Background/js/script.js @@ -7,6 +7,6 @@ body.style.backgroundColor = 'violet' button.addEventListener('click', changeBackground) function changeBackground(){ -const colorIndex= parseInt(Math.random()*colors.length+1) +const colorIndex= parseInt(Math.random()*colors.length-1) body.style.backgroundColor = colors[colorIndex] }