Skip to content

Commit b79d1b6

Browse files
author
Ogbemi mene
committed
commit for quote app
1 parent 4222cda commit b79d1b6

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

File renamed without changes.

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+
function displayRandomQuote() {
495+
const quoteP = document.getElementById("quote");
496+
const authorP = document.getElementById("author");
497+
498+
const selectedQuote = pickFromArray(quotes);
499+
500+
quoteP.textContent = selectedQuote.quote;
501+
authorP.textContent = selectedQuote.author;
502+
}
503+
504+
// Setup event listener and display initial quote on load
505+
window.addEventListener("DOMContentLoaded", () => {
506+
displayRandomQuote();
507+
508+
const newQuoteBtn = document.getElementById("new-quote");
509+
newQuoteBtn.addEventListener("click", displayRandomQuote);
510+
});

0 commit comments

Comments
 (0)