diff --git a/script.js b/script.js index df7707d..dba9bb1 100644 --- a/script.js +++ b/script.js @@ -6,21 +6,19 @@ const newQuoteBtn = document.getElementById("new-quote"); const loader = document.getElementById('loader'); let apiQuotes = []; -// Show loading -function loading() { +function showLoadingSpinner() { loader.hidden = false; quoteContainer.hidden = true; } -// Hide loading -function complete() { +function removeLoadingSpinner() { quoteContainer.hidden = false; loader.hidden = true; } // Show new quote function newQuote() { - loading(); + showLoadingSpinner(); // Pick a random quote from apiQuotes array const quote = apiQuotes[Math.floor(Math.random() * apiQuotes.length)]; // check if author field is blank and replace it with 'unknown' @@ -37,19 +35,19 @@ function newQuote() { } // set quote, hide loader quoteText.textContent = quote.text; - complete(); + removeLoadingSpinner(); } // Get quotes from API async function getQuotes() { - loading(); + showLoadingSpinner(); const apiUrl = "https://jacintodesign.github.io/quotes-api/data/quotes.json"; try { const response = await fetch(apiUrl); apiQuotes = await response.json(); newQuote(); } catch (error) { - // catch error + console.error; } }