Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!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</title>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>hello there</h1>
Expand Down
13 changes: 13 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,16 @@ const quotes = [
];

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

const quoteText = document.getElementById("quote");
const authorText = document.getElementById("author");

const newQuoteBtn = document.getElementById("new-quote");

newQuoteBtn.addEventListener("click", () => {
const selectedQuote = pickFromArray(quotes);
quoteText.textContent = selectedQuote.quote;
authorText.textContent = `-- ${selectedQuote.author}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The leading -- appears to be for styling purposes. Keeping it in the CSS or in HTML could allow us to adjust the view without changing any JavaScript code.

});

document.onload = newQuoteBtn.click();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why assign the return value of .click() to document.onload?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

meant to do window.onload = () => newQuoteBtn.click();

Now uses function to generate quote and calls that instead.

3 changes: 3 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/** Write your CSS in here **/
#author {
font-style: italic;
}
Loading