Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
</head>
<body>
Expand Down
12 changes: 12 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// pickFromArray(['a','b','c','d']) // maybe returns 'c'

// You don't need to change this function

function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}
Expand Down Expand Up @@ -490,4 +491,15 @@ const quotes = [
},
];

function showQuote() {
const selectedQuote = pickFromArray(quotes);
document.getElementById("quote").textContent = selectedQuote.quote;
document.getElementById("author").textContent = selectedQuote.author;
}
showQuote();

document.getElementById("new-quote").addEventListener("click", showQuote);
setInterval(showQuote, 5000);


// call pickFromArray with the quotes array to check you get a random quote
Loading