Skip to content

Commit ccc7e21

Browse files
committed
implement quote generator logic in js file
1 parent 1a5069a commit ccc7e21

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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+
const quoteEl = document.querySelector("#quote");
495+
const authorEl = document.querySelector("#author");
496+
const button = document.querySelector("#new-quote");
497+
498+
function displayQuote() {
499+
const randomQuote = pickFromArray(quotes);
500+
501+
quoteEl.textContent = randomQuote.quote;
502+
authorEl.textContent = randomQuote.author;
503+
}
504+
505+
// Show initial quote on page load
506+
displayQuote();
507+
508+
// Change quote when button is clicked
509+
button.addEventListener("click", displayQuote);

0 commit comments

Comments
 (0)