Skip to content

Commit d18e2b0

Browse files
committed
Extract function to avoid duplication
1 parent 4354165 commit d18e2b0

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎Sprint-3/quote-generator/quotes.js‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
document.addEventListener("DOMContentLoaded", () => {
1+
const showNewQuote = () => {
22
const {quote, author} = pickFromArray(quotes);
33
document.getElementById("quote").innerText = quote;
44
document.getElementById("author").innerText = author;
5-
});
5+
};
66

7-
document.querySelector("button").addEventListener("click", () => {
8-
const {quote, author} = pickFromArray(quotes);
9-
document.getElementById("quote").innerText = quote;
10-
document.getElementById("author").innerText = author;
11-
});
7+
document.addEventListener("DOMContentLoaded", () => { showNewQuote(); });
8+
9+
document.querySelector("button").addEventListener("click", () => { showNewQuote(); });
1210

1311
// DO NOT EDIT BELOW HERE
1412

0 commit comments

Comments
 (0)