Skip to content

Commit 6ffb055

Browse files
display_quote_implementation
1 parent c079ba2 commit 6ffb055

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 fetchQuote = document.getElementById("quote");
495+
const fetchAuthor = document.getElementById("author");
496+
const newQuote = document.getElementById("new-quote");
497+
498+
// function to display a random quote
499+
function displayRandomQuote() {
500+
const randomQuote = pickFromArray(quotes);
501+
fetchQuote.innerText = randomQuote.quote;
502+
fetchAuthor.innerText = randomQuote.author;
503+
}
504+
505+
// show one quote when page loads
506+
displayRandomQuote();
507+
508+
// change quote when button is clicked
509+
newQuote.addEventListener("click", displayRandomQuote);

0 commit comments

Comments
 (0)