diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..befe8788e 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -1,9 +1,9 @@ - + - Title here + Quote generator app diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..8f9b16a6c 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -19,6 +19,18 @@ function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } +function quotesAndAuthor() { + const randomQuote = pickFromArray(quotes); + document.querySelector("#quote").innerText = randomQuote.quote; + document.querySelector("#author").innerText = randomQuote.author; +} +function setup() { + quotesAndAuthor(); // show a quote on load + document.getElementById("new-quote").addEventListener("click", () => { + quotesAndAuthor(); + }); +} +window.onload = setup; // A list of quotes you can use in your app. // DO NOT modify this array, otherwise the tests may break!