diff --git a/script.js b/script.js index 63e96a5..2449cbb 100644 --- a/script.js +++ b/script.js @@ -54,7 +54,7 @@ function changeColor() { switch (buttonID) { case "rgbColor": - colorValue = "red"; + colorValue = rgbColor(); break; case "whiteColor": colorValue = "white"; @@ -77,4 +77,14 @@ function changeColor() { } } +function rgbColor() { + let r = Math.floor(Math.random() * 255); + let g = Math.floor(Math.random() * 255); + let b = Math.floor(Math.random() * 255); + + let rgbCol = "rgb(" + r + "," + g+ "," + b +")"; + + return rgbCol; +} + createGrid(); \ No newline at end of file