From 0313e2f0fd4f8c59faa49875f66209e7767622d7 Mon Sep 17 00:00:00 2001 From: Miguel Almodovar Date: Mon, 22 Jan 2024 18:26:25 -0400 Subject: [PATCH] declared facts as a constant --- index.html | 2 +- scripts.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index b23ee5a..3b0e267 100644 --- a/index.html +++ b/index.html @@ -102,7 +102,7 @@ - + diff --git a/scripts.js b/scripts.js index 978b103..dd1b6d6 100644 --- a/scripts.js +++ b/scripts.js @@ -17,16 +17,20 @@ document.addEventListener('DOMContentLoaded', function() { .then(quotes => { let currentQuoteIndex = 0; const quoteBanner = document.getElementById('quoteBanner'); + const quoteText = quoteBanner.querySelector('blockquote p'); function updateQuote() { - quoteBanner.textContent = quotes[currentQuoteIndex++]; - if (currentQuoteIndex >= quotes.length) currentQuoteIndex = 0; + quoteText.textContent = quotes[currentQuoteIndex]; + currentQuoteIndex = (currentQuoteIndex + 1) % quotes.length; } updateQuote(); setInterval(updateQuote, 5000); - }); + }) + .catch(error => console.error('Error loading JSON:', error)); }); + +