From 3642bceef463e04f237288a01a1bb3e213d2d1a1 Mon Sep 17 00:00:00 2001 From: Alaa Tagi Date: Wed, 26 Nov 2025 15:34:58 +0000 Subject: [PATCH] implement a quote-generator function and modify index.html code --- Sprint-3/quote-generator/index.html | 11 ++++++----- Sprint-3/quote-generator/quotes.js | 9 +++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..aaeef90aa 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,13 +3,14 @@ - Title here + Quote generator app -

hello there

-

-

- +

Quote Generator

+

+

+

+ diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..3ae0de846 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -19,7 +19,16 @@ function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } +function showRandomQuote() { + const randomQuote = pickFromArray(quotes); + const quoteText = document.getElementById("quote-text"); + const quoteAuthor = document.getElementById("quote-author"); + quoteText.innerText = `"${randomQuote.quote}"`; + quoteAuthor.innerText = `- ${randomQuote.author}`; +} +window.onload = showRandomQuote; +document.getElementById("new-quote-button").addEventListener("click", showRandomQuote); // A list of quotes you can use in your app. // DO NOT modify this array, otherwise the tests may break! const quotes = [