From 9606a7988b35e60240eddb2f49d9b3669516ec85 Mon Sep 17 00:00:00 2001 From: SalahAlsabhi Date: Thu, 12 Nov 2026 12:17:53 +0000 Subject: [PATCH] Quote generator: show random quote on load and on New quote click --- Sprint-3/quote-generator/index.html | 5 +++-- Sprint-3/quote-generator/quotes.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..88f32f473 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,11 +3,12 @@ - Title here + Quote generator app + -

hello there

+

Quote generator app

diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..ed4b895b6 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -491,3 +491,16 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote + +const quoteEl = document.querySelector("#quote"); +const authorEl = document.querySelector("#author"); +const newQuoteButton = document.querySelector("#new-quote"); + +function showRandomQuote() { + const chosen = pickFromArray(quotes); + quoteEl.textContent = chosen.quote; + authorEl.textContent = chosen.author; +} + +showRandomQuote(); +newQuoteButton.addEventListener("click", showRandomQuote);