Skip to content
Closed
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 @@ -19,6 +19,18 @@
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}
function quotesAndAuthor() {
const randomQuote = pickFromArray(quotes);
document.querySelector("#quote").innerText = randomQuote.quote;
document.querySelector("#author").innerText = randomQuote.author;
}
function setup() {
quotesAndAuthor(); // show a quote on load
document.getElementById("new-quote").addEventListener("click", () => {
quotesAndAuthor();
});
}
window.onload = setup;
Comment on lines +22 to +33

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done this works well.


// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
Expand Down
Loading