declared facts as a constant

This commit is contained in:
Miguel Almodovar 2024-01-22 18:26:25 -04:00
parent f45d60abba
commit 0313e2f0fd
2 changed files with 8 additions and 4 deletions

View file

@ -102,7 +102,7 @@
</div>
</div>
<script src="scripts.js"></script>
<script src="./scripts.js"></script>
</section>

View file

@ -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));
});