Skip to content

Commit 6d4e004

Browse files
authored
Add quote display functionality with button
1 parent 72ced8a commit 6d4e004

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎Sprint-3/quote-generator/quotes.js‎

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

493493
// call pickFromArray with the quotes array to check you get a random quote
494+
495+
496+
const quoteElement = document.getElementById("quote");
497+
const authorElement = document.getElementById("author");
498+
const newQuoteButton = document.getElementById("new-quote");
499+
500+
501+
function displayQuote() {
502+
const randomQuote = pickFromArray(quotes);
503+
504+
quoteElement.textContent = `"${randomQuote.quote}"`;
505+
authorElement.textContent = `- ${randomQuote.author}`;
506+
}
507+
508+
509+
displayQuote();
510+
511+
512+
newQuoteButton.addEventListener("click", displayQuote);

0 commit comments

Comments
 (0)