From e3fb3192c362b083e84023b19f478256c8c851c2 Mon Sep 17 00:00:00 2001 From: Brian Ndickers <47857858+bryondickers@users.noreply.github.com> Date: Thu, 20 Oct 2022 00:59:27 +0300 Subject: [PATCH] using destructuring on arrays --- js/script.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/script.js b/js/script.js index 7e270c0..6ddfb37 100644 --- a/js/script.js +++ b/js/script.js @@ -1,6 +1,6 @@ //Object Array to hold quotes, sources, citaitons and years -var quotes = [ +const quotes = [ { quote: "Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.", source: "Dr. Seuss" @@ -172,10 +172,10 @@ function getRandomQuote () { //Function to select random rgb color value function getRandomColor () { - var red = Math.floor(Math.random() * 256 ); - var green = Math.floor(Math.random() * 256 ); - var blue = Math.floor(Math.random() * 256 ); - var randomColor = 'rgb(' + red + ',' + green + ',' + blue + ')'; + var [red, green, blue] = [Math.random() * 256, Math.random() * 256, Math.random() * 256 ]; + + + var randomColor = 'rgb(' + Math.floor(red) + ',' + Math.floor(green) + ',' + Math.floor(blue) + ')'; return randomColor; }