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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirements for this project are that it shows a quote on load, and optionally has a button you can click to have it auto-play more quotes.

I don't see a button in your UI when I load it, but it does auto-play quotes from the time it loads.

Can you work out how to gate this behaviour behind clicking a button, rather than just always doing it?



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