Skip to content

Commit f0e1a0d

Browse files
authored
Implement random quote display functionality
Added displayRandomQuote function to show a random quote and author on button click.
1 parent 222323e commit f0e1a0d

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

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

493493
// call pickFromArray with the quotes array to check you get a random quote
494+
function displayRandomQuote() {
495+
const selectedQuote = pickFromArray(quotes);
496+
497+
document.getElementById("quote").textContent = selectedQuote.quote;
498+
document.getElementById("author").textContent = selectedQuote.author;
499+
}
500+
501+
function setup() {
502+
const newQuoteButton = document.getElementById("new-quote");
503+
504+
newQuoteButton.addEventListener("click", displayRandomQuote);
505+
506+
displayRandomQuote();
507+
}
508+
509+
window.onload = setup;

0 commit comments

Comments
 (0)