From df37abdba0cdb065fd479876b3dff8b37cd3632a Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:00:42 +0000 Subject: [PATCH 1/7] update title --- Sprint-3/quote-generator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..5f6a720f1 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,7 +3,7 @@ - Title here + Quote generator app From 31fcc7d0bc3c07775ca038a4e26f7168186cfb55 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 9 Mar 2026 08:51:27 +0000 Subject: [PATCH 2/7] Add functionality to display a random quote on page load --- Sprint-3/quote-generator/quotes.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..4eab02865 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -20,6 +20,8 @@ function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } + + // A list of quotes you can use in your app. // DO NOT modify this array, otherwise the tests may break! const quotes = [ @@ -491,3 +493,10 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote + +//window.addEventListener("load",pickFromArray(quotes)) +const randomQuote = pickFromArray(quotes); +const quote=document.getElementById("quote") +const author=document.getElementById("author") +quote.innerText=randomQuote.quote +author.innerText=randomQuote.author From 670779a25e26822edc1486182edcb02e862dcfbb Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 9 Mar 2026 09:37:51 +0000 Subject: [PATCH 3/7] add button functionality for new quotes --- Sprint-3/quote-generator/quotes.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4eab02865..703d83fe0 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -20,8 +20,6 @@ function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } - - // A list of quotes you can use in your app. // DO NOT modify this array, otherwise the tests may break! const quotes = [ @@ -494,9 +492,21 @@ const quotes = [ // call pickFromArray with the quotes array to check you get a random quote -//window.addEventListener("load",pickFromArray(quotes)) const randomQuote = pickFromArray(quotes); -const quote=document.getElementById("quote") -const author=document.getElementById("author") -quote.innerText=randomQuote.quote -author.innerText=randomQuote.author + +const quote = document.getElementById("quote"); +quote.innerText = randomQuote.quote; + +const author = document.getElementById("author"); +author.innerText = randomQuote.author; + +const button = document.getElementById("new-quote"); +button.addEventListener("click", () => { + const randomQuote = pickFromArray(quotes); + + const quote = document.getElementById("quote"); + quote.innerText = randomQuote.quote; + + const author = document.getElementById("author"); + author.innerText = randomQuote.author; +}); From 0015e404bc3543a418a8b5273924c0ca7394a071 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:18:31 +0000 Subject: [PATCH 4/7] replace pickFromArray with direct random selection from quotes array --- Sprint-3/quote-generator/quotes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 703d83fe0..94af3c242 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -492,7 +492,7 @@ const quotes = [ // call pickFromArray with the quotes array to check you get a random quote -const randomQuote = pickFromArray(quotes); +const randomQuote = quotes[Math.floor(Math.random()*quotes.length)]; const quote = document.getElementById("quote"); quote.innerText = randomQuote.quote; @@ -502,7 +502,7 @@ author.innerText = randomQuote.author; const button = document.getElementById("new-quote"); button.addEventListener("click", () => { - const randomQuote = pickFromArray(quotes); + const randomQuote =quotes[Math.floor(Math.random()*quotes.length)]; const quote = document.getElementById("quote"); quote.innerText = randomQuote.quote; From be903f2ce6e2a2b62aa496a414aa0fde4bc402a4 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 9 Mar 2026 16:36:21 +0000 Subject: [PATCH 5/7] Add auto-play functionality to display quotes at intervals --- Sprint-3/quote-generator/quotes.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 94af3c242..9ecfb16cb 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -510,3 +510,25 @@ button.addEventListener("click", () => { const author = document.getElementById("author"); author.innerText = randomQuote.author; }); + +function chooseQuote(){ + const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; + + const quote = document.getElementById("quote"); + quote.innerText = randomQuote.quote; + + const author = document.getElementById("author"); + author.innerText = randomQuote.author; +} +const autoGenerate = document.getElementById("auto-play-toggle"); +let interval = null; +autoGenerate.addEventListener("change",()=>{ + + if(autoGenerate.checked){ + interval=setInterval(chooseQuote,2000) + }else{ + clearInterval(interval) + interval=null + } +}) + From 17571ba03204d0e7d62049a6d36a1888a73cdd70 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 9 Mar 2026 16:36:35 +0000 Subject: [PATCH 6/7] Fix HTML doctype and add auto-generate toggle checkbox --- Sprint-3/quote-generator/index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 5f6a720f1..a31ca66c6 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -1,4 +1,4 @@ - + @@ -7,6 +7,9 @@ +

hello there

From ea60dd5a3d3f89c80ac2ddf8f96c1b2c3ced1ba1 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 9 Mar 2026 16:43:56 +0000 Subject: [PATCH 7/7] Refactor quote selection logic into a reusable function and update event listeners for better readability --- Sprint-3/quote-generator/quotes.js | 41 ++++++++++-------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 9ecfb16cb..abdd39192 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -492,43 +492,28 @@ const quotes = [ // call pickFromArray with the quotes array to check you get a random quote -const randomQuote = quotes[Math.floor(Math.random()*quotes.length)]; - -const quote = document.getElementById("quote"); -quote.innerText = randomQuote.quote; - -const author = document.getElementById("author"); -author.innerText = randomQuote.author; - -const button = document.getElementById("new-quote"); -button.addEventListener("click", () => { - const randomQuote =quotes[Math.floor(Math.random()*quotes.length)]; +function chooseQuote() { + const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; const quote = document.getElementById("quote"); quote.innerText = randomQuote.quote; const author = document.getElementById("author"); author.innerText = randomQuote.author; -}); +} -function chooseQuote(){ - const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; +window.addEventListener("load", chooseQuote); - const quote = document.getElementById("quote"); - quote.innerText = randomQuote.quote; +const button = document.getElementById("new-quote"); +button.addEventListener("click", chooseQuote); - const author = document.getElementById("author"); - author.innerText = randomQuote.author; -} const autoGenerate = document.getElementById("auto-play-toggle"); let interval = null; -autoGenerate.addEventListener("change",()=>{ - - if(autoGenerate.checked){ - interval=setInterval(chooseQuote,2000) - }else{ - clearInterval(interval) - interval=null +autoGenerate.addEventListener("change", () => { + if (autoGenerate.checked) { + interval = setInterval(chooseQuote, 2000); + } else { + clearInterval(interval); + interval = null; } -}) - +});