diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..f7ad48f79 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,11 +3,11 @@ - Title here + Quote generator -

hello there

+

Quote generator

diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..63c370509 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -491,3 +491,23 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote + +const quoteElem = document.getElementById("quote"); +const authorElem = document.getElementById("author"); +const newQuoteBtn = document.getElementById("new-quote"); + +function getRandomQuote() { + return pickFromArray(quotes); +} + +function displayQuote(quote) { + quoteElem.textContent = quote.quote; + authorElem.textContent = quote.author; +} + +function showRandomQuote() { + displayQuote(getRandomQuote()); +} + +newQuoteBtn.addEventListener("click", showRandomQuote); +showRandomQuote();