Skip to content

Commit 8897da1

Browse files
committed
add loadQuote function to generate quotes. Use window load event listener to call that function instead of triggering click event.
1 parent 1130932 commit 8897da1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Sprint-3/quote-generator/quotes.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,12 @@ const authorText = document.getElementById("author");
497497

498498
const newQuoteBtn = document.getElementById("new-quote");
499499

500-
newQuoteBtn.addEventListener("click", () => {
500+
function loadQuote() {
501501
const selectedQuote = pickFromArray(quotes);
502502
quoteText.textContent = selectedQuote.quote;
503-
authorText.textContent = `-- ${selectedQuote.author}`;
504-
});
503+
authorText.textContent = selectedQuote.author;
504+
}
505+
506+
newQuoteBtn.addEventListener("click", loadQuote);
505507

506-
document.onload = newQuoteBtn.click();
508+
window.addEventListener("load", loadQuote);

0 commit comments

Comments
 (0)