Skip to content

Commit 8eb4652

Browse files
Writing the function that change to random quote with their author
1 parent ba9667d commit 8eb4652

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Sprint-3/quote-generator/quotes.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,18 @@ const quotes = [
491491
];
492492

493493
// call pickFromArray with the quotes array to check you get a random quote
494+
495+
function showRandomQuote() {
496+
const randomQuote = pickFromArray(quotes);
497+
498+
const quoteP = document.querySelector("#quote");
499+
const authorP = document.querySelector("#author");
500+
501+
quoteP.innerText = randomQuote.quote;
502+
authorP.innerText = randomQuote.author;
503+
}
504+
505+
showRandomQuote();
506+
507+
const newQuoteBtn = document.querySelector("#new-quote");
508+
newQuoteBtn.addEventListener("click", showRandomQuote);

0 commit comments

Comments
 (0)