Skip to content

Commit 20c667d

Browse files
committed
feat: implement displayQuote function to show random quotes
1 parent 2c5d12f commit 20c667d

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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+
<link rel="icon" href="" />
8+
<link rel="stylesheet" href="./style.css" />
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,16 @@ const quotes = [
491491
];
492492

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

0 commit comments

Comments
 (0)