diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcfb..befe8788e2 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 4a4d04b722..c9c90896f1 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -16,6 +16,7 @@ // pickFromArray(['a','b','c','d']) // maybe returns 'c' // You don't need to change this function + function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } @@ -490,4 +491,15 @@ const quotes = [ }, ]; +function showQuote() { + const selectedQuote = pickFromArray(quotes); + document.getElementById("quote").textContent = selectedQuote.quote; + document.getElementById("author").textContent = selectedQuote.author; +} +showQuote(); + +document.getElementById("new-quote").addEventListener("click", showQuote); +setInterval(showQuote, 5000); + + // call pickFromArray with the quotes array to check you get a random quote