Cape Town | 2026-ITP-Jan | Isaac Abodunrin | Sprint 3 | Grouping data: Quote generator#1181
Conversation
Sprint-3/quote-generator/quotes.js
Outdated
| const author = document.querySelector("#author"); | ||
|
|
||
| quote.textContent = randomQuote.quote; | ||
| author.textContent = `- ${randomQuote.author}`; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
You're absolutely right -- removing the - from JavaScript would be better for separation of concerns. I've moved the - into the CSS. I've also moved the leading “ in front of each quote from the HTML into the CSS so it's more consistent.
Sprint-3/quote-generator/quotes.js
Outdated
| newQuoteButton.addEventListener("click", displayQuote); | ||
| window.addEventListener("load", displayQuote); |
There was a problem hiding this comment.
The code that setup the event listener once is also part of the "run on load" code.
You can consider including all the "run on load" code in 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
});There was a problem hiding this comment.
Thanks for the suggestion CJ. I've gone ahead and wrapped the code needed to run on loading into a setup function.
|
Looks good. Well done. |
Self checklist
Changelist
quote_generator_example.pngas a guide.