London | 26-ITP-May | Raihan Sharif | Sprint 3 | Quote Generator#1221
Open
RaihanSharif wants to merge 3 commits intoCodeYourFuture:mainfrom
Open
London | 26-ITP-May | Raihan Sharif | Sprint 3 | Quote Generator#1221RaihanSharif wants to merge 3 commits intoCodeYourFuture:mainfrom
RaihanSharif wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
May 10, 2026
Contributor
cjyuan
left a comment
There was a problem hiding this comment.
Placing all the "run on load" code in one place can make it clearer that
"this is what runs when the page loads."
Consider organizing the code in the following manner:
// Function definitions
function showQuote() {
...
}
...
window.addEventListener('load', function() {
// code to be executed on page load, including code that setup event listeners
});| newQuoteBtn.addEventListener("click", () => { | ||
| const selectedQuote = pickFromArray(quotes); | ||
| quoteText.textContent = selectedQuote.quote; | ||
| authorText.textContent = `-- ${selectedQuote.author}`; |
Contributor
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.
| authorText.textContent = `-- ${selectedQuote.author}`; | ||
| }); | ||
|
|
||
| document.onload = newQuoteBtn.click(); |
Contributor
There was a problem hiding this comment.
Why assign the return value of .click() to document.onload?
Author
There was a problem hiding this comment.
meant to do window.onload = () => newQuoteBtn.click();
Now uses function to generate quote and calls that instead.
…ener to call that function instead of triggering click event.
Contributor
|
Changes look good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
On page load display random quote. On button click display random quote.