Skip to content

Commit 4c6f9e9

Browse files
committed
I have improved my code and got the qoute generator to function
1 parent 17893af commit 4c6f9e9

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
<link rel="stylesheet" href="style.css" />
99
</head>
1010
<body>
11-
<h1>hello there</h1>
12-
<p id="quote"></p>
13-
<p id="author"></p>
11+
<div id="quote-container">
12+
<h1>Quote Generator</h1>
1413

15-
<button type="button" id="new-quote">New quote</button>
16-
<input id="quote-input" type="text" placeholder="Enter a quote here" />
17-
<input id="author-input" type="text" placeholder="Enter the author here" />
14+
<p id="quote"></p>
15+
<p id="author"></p>
1816

19-
<button type="button" id="add-quote">Add quote</button>
20-
17+
<button type="button" id="new-quote">New quote</button>
18+
</div>
2119
</body>
2220
</html>

Sprint-3/quote-generator/quotes.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
const quoteElement = document.getElementById("quote");
2+
const authorElement = document.getElementById("author");
3+
const newQuoteButton = document.getElementById("new-quote");
4+
5+
function showQuote(quoteObject) {
6+
quoteElement.textContent = quoteObject.quote;
7+
authorElement.textContent = quoteObject.author;
8+
}
9+
10+
function showRandomQuote() {
11+
const randomQuote = pickFromArray(quotes);
12+
showQuote(randomQuote);
13+
}
14+
15+
window.addEventListener("load", function () {
16+
showRandomQuote();
17+
18+
newQuoteButton.addEventListener("click", function () {
19+
showRandomQuote();
20+
});
21+
});
22+
123
// DO NOT EDIT BELOW HERE
224

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

Sprint-3/quote-generator/style.css

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** Write your CSS in here **/
22
body {
33
font-family: Arial, sans-serif;
4-
background-color: #f0f0f0;
4+
background-color:burlywood;
55
padding: 20px;
66
}
77

@@ -12,6 +12,7 @@ body {
1212
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
1313
max-width: 600px;
1414
margin: auto;
15+
text-align: center;
1516
}
1617
#quote {
1718
font-size: 24px;
@@ -20,19 +21,24 @@ body {
2021
}
2122
#author {
2223
font-size: 20px;
23-
text-align: right;
24+
text-align: center;
2425
margin-bottom: 20px;
26+
color: #555;
2527
}
2628
button {
29+
background-color: #007BFF;
30+
color: white;
2731
padding: 10px 20px;
2832
font-size: 16px;
2933
cursor: pointer;
3034
}
31-
#quote-input, #author-input {
32-
padding: 10px;
33-
font-size: 16px;
34-
margin-right: 10px;
35+
36+
h1 {
37+
color: #333;
38+
margin-bottom: 20px;
3539
}
3640

3741

3842

43+
44+

0 commit comments

Comments
 (0)