Skip to content

Commit 2bd68b2

Browse files
committed
update html title and and on page load code in a function
1 parent a854ec3 commit 2bd68b2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Title here</title>
6+
<title>Quote generator app</title>
77
<link rel="stylesheet" href="style.css">
88
<script defer src="quotes.js"></script>
99
</head>
@@ -17,5 +17,3 @@
1717
</section>
1818
</body>
1919
</html>
20-
21-

Sprint-3/quote-generator/quotes.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,7 @@ const quotes = [
489489
author: "Zig Ziglar",
490490
},
491491
];
492-
const title = document.querySelector("title")
493-
title.textContent = "Quote generator app";
492+
494493
// call pickFromArray with the quotes array to check you get a random quote
495494
const quoteEl = document.querySelector("#quote");
496495
const authorEl = document.querySelector("#author");
@@ -504,7 +503,10 @@ function displayQuote() {
504503
}
505504

506505
// Show initial quote on page load
507-
displayQuote();
506+
function setup() {
507+
displayQuote();
508508

509-
// Change quote when button is clicked
510-
button.addEventListener("click", displayQuote);
509+
// Change quote when button is clicked
510+
button.addEventListener("click", displayQuote);
511+
}
512+
window.addEventListener("load", setup)

0 commit comments

Comments
 (0)