Skip to content

Commit 9128df8

Browse files
authored
Add function to display random quotes
1 parent 60476fe commit 9128df8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

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

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

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

0 commit comments

Comments
 (0)