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
2 changes: 1 addition & 1 deletion Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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
15 changes: 15 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,18 @@ const quotes = [
];

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

function showRandomQuote() {
const randomQuote = pickFromArray(quotes);

const quoteP = document.querySelector("#quote");
const authorP = document.querySelector("#author");

quoteP.innerText = randomQuote.quote;
authorP.innerText = randomQuote.author;
}

showRandomQuote();

const newQuoteBtn = document.querySelector("#new-quote");
newQuoteBtn.addEventListener("click", showRandomQuote);
Comment on lines +505 to +508
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.

Could consider placing all the "run on load" code inside a function to make it clearer that
"this is what runs when the page loads." For examples,

function setup() {
  // code to be executed on page load
}

window.addEventListener('load', setup);

or

window.addEventListener('load', function() {
  // code to be executed on page load
});

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.

Thank you for the feed back I will post the answer here when I am done thank you.

Loading