From d64ad44b1d12beb6e695a6f135f732c5eb7afd3d Mon Sep 17 00:00:00 2001 From: Alex Jamshidi Date: Thu, 14 May 2026 05:22:42 +0100 Subject: [PATCH 1/2] app created, tests passed --- Sprint-3/quote-generator/index.html | 4 ++-- Sprint-3/quote-generator/quotes.js | 31 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..3705dadea 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,11 +3,11 @@ - Title here + Quote Generator App -

hello there

+

Random Quote:

diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..741e92316 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -491,3 +491,34 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote + +function setup() { + updateQuote(); + appendQuote(); +} + +const state = { + quote: "", + author: "", +}; + +function updateQuote() { + const chosenQuote = pickFromArray(quotes); + state.quote = chosenQuote.quote; + state.author = chosenQuote.author; +} + +function appendQuote() { + const quoteElem = document.getElementById("quote"); + const authorElem = document.getElementById("author"); + quoteElem.textContent = ""; + authorElem.textContent = ""; + quoteElem.append(state.quote); + authorElem.append(state.author); +} + +document.getElementById("new-quote").addEventListener("click", function () { + setup(); +}); + +window.onload = setup; From 859ac64ede2e12e5578332aa3903b417b467059f Mon Sep 17 00:00:00 2001 From: Alex Jamshidi Date: Thu, 14 May 2026 18:29:19 +0100 Subject: [PATCH 2/2] PR changed made --- Sprint-3/quote-generator/quotes.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 741e92316..202e72ce4 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -492,9 +492,9 @@ const quotes = [ // call pickFromArray with the quotes array to check you get a random quote -function setup() { +function showNewQuote() { updateQuote(); - appendQuote(); + replaceQuote(); } const state = { @@ -508,17 +508,15 @@ function updateQuote() { state.author = chosenQuote.author; } -function appendQuote() { +function replaceQuote() { const quoteElem = document.getElementById("quote"); const authorElem = document.getElementById("author"); - quoteElem.textContent = ""; - authorElem.textContent = ""; - quoteElem.append(state.quote); - authorElem.append(state.author); + quoteElem.textContent = state.quote; + authorElem.textContent = state.author; } document.getElementById("new-quote").addEventListener("click", function () { - setup(); + showNewQuote(); }); -window.onload = setup; +window.onload = showNewQuote;