Skip to content

Commit e6fefea

Browse files
implemented the function that display quotes
1 parent 93e950c commit e6fefea

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
@@ -1,3 +1,20 @@
1+
// Goal: page shows a random quote from the quotes array with displaying the author
2+
// requirements:
3+
// when clicking a button on the screen it changes the quote
4+
const author = document.getElementById("author");
5+
const quote = document.getElementById("quote");
6+
const newQuoteButton = document.getElementById("new-quote");
7+
8+
newQuoteButton.addEventListener("click", () => {
9+
displayQuote();
10+
});
11+
12+
function displayQuote() {
13+
const randomQuote = pickFromArray(quotes);
14+
quote.textContent = randomQuote.quote;
15+
author.textContent = randomQuote.author;
16+
}
17+
118
// DO NOT EDIT BELOW HERE
219

320
// pickFromArray is a function which will return one item, at

0 commit comments

Comments
 (0)