Skip to content

Commit 1a42b39

Browse files
updated function and styled in html
1 parent 10b3ac9 commit 1a42b39

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
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>
7+
<style>
8+
body {
9+
display: grid;
10+
place-items: center;
11+
min-height: 100vh;
12+
margin: 0;
13+
font-family: Arial, sans-serif;
14+
text-align: center;
15+
margin-top: 40px;
16+
background-color: aqua;
17+
}
18+
h1 {
19+
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
20+
color: green;
21+
}
22+
23+
#quote {
24+
font-size: 45px;
25+
margin-bottom: 10px;
26+
color: purple;
27+
}
28+
#author {
29+
font-size: 30px;
30+
color: red;
31+
margin-bottom: 10px;
32+
font-family: Cambria, Cochin, Georgia, Times, "Times New Roman", serif;
33+
}
34+
#new-quote {
35+
padding: 10px 20px;
36+
font-size: 16px;
37+
}
38+
</style>
739
<script defer src="quotes.js"></script>
840
</head>
941
<body>
10-
<h1>hello there</h1>
42+
<h1>Welcome to the Quote Generator</h1>
1143
<p id="quote"></p>
1244
<p id="author"></p>
1345
<button type="button" id="new-quote">New quote</button>

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+
// DO NOT EDIT ABOVE HERE
2+
window.addEventListener("DOMContentLoaded", () => {
3+
const quoteElement = document.getElementById("quote");
4+
const authorElement = document.getElementById("author");
5+
const newQuoteBtn = document.getElementById("new-quote");
6+
7+
function displayRandomQuote() {
8+
const randomQuote = pickFromArray(quotes);
9+
quoteElement.textContent = `"${randomQuote.quote}"`;
10+
authorElement.textContent = randomQuote.author;
11+
}
12+
13+
displayRandomQuote();
14+
15+
newQuoteBtn.addEventListener("click", displayRandomQuote);
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)