Skip to content

Commit fff2726

Browse files
committed
Implement quote display functionality and update HTML structure
1 parent cd4c69f commit fff2726

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="./style.css" />
67
<title>Title here</title>
8+
79
<script defer src="quotes.js"></script>
810
</head>
911
<body>
10-
<h1>hello there</h1>
1112
<p id="quote"></p>
1213
<p id="author"></p>
1314
<button type="button" id="new-quote">New quote</button>

Sprint-3/quote-generator/quotes.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,14 @@ const quotes = [
491491
];
492492

493493
// call pickFromArray with the quotes array to check you get a random quote
494+
let quote = document.getElementById("quote");
495+
let author = document.getElementById("author");
496+
let quoteButton = document.getElementById("new-quote");
497+
498+
function displayQuote() {
499+
let randomQuote = pickFromArray(quotes);
500+
quote.textContent = randomQuote.quote;
501+
author.textContent = randomQuote.author;
502+
}
503+
displayQuote();
504+
quoteButton.addEventListener("click", displayQuote);

0 commit comments

Comments
 (0)