Skip to content

Commit 79e6a16

Browse files
author
Pretty Taruvinga
committed
Add Sprint-3 quote generator only
1 parent 53fa90f commit 79e6a16

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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</title>
77
<script defer src="quotes.js"></script>
88
</head>
99
<body>
10-
<h1>hello there</h1>
10+
<h1>Quote Generator</h1>
1111
<p id="quote"></p>
1212
<p id="author"></p>
1313
<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
@@ -1,3 +1,15 @@
1+
const quoteP = document.querySelector("#quote");
2+
const authorP = document.querySelector("#author");
3+
const button = document.querySelector("#new-quote");
4+
5+
function displayQuote() {
6+
const randomQuote = pickFromArray(quotes);
7+
quoteP.innerText = randomQuote.quote;
8+
authorP.innerText = randomQuote.author;
9+
}
10+
11+
button.addEventListener("click", displayQuote);
12+
113
// DO NOT EDIT BELOW HERE
214

315
// pickFromArray is a function which will return one item, at
@@ -491,3 +503,4 @@ const quotes = [
491503
];
492504

493505
// call pickFromArray with the quotes array to check you get a random quote
506+
displayQuote();

0 commit comments

Comments
 (0)