Skip to content

Glasgow | 26-ITP-Jan| Martin McLean |Sprint 3|Quote Generator#1030

Open
mjm-git185 wants to merge 7 commits intoCodeYourFuture:mainfrom
mjm-git185:quotes
Open

Glasgow | 26-ITP-Jan| Martin McLean |Sprint 3|Quote Generator#1030
mjm-git185 wants to merge 7 commits intoCodeYourFuture:mainfrom
mjm-git185:quotes

Conversation

@mjm-git185
Copy link
Copy Markdown

Changelist

I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
My changes meet the requirements of the task
I have tested my changes
My changes follow the style guide
my coursework

@github-actions

This comment has been minimized.

@mjm-git185 mjm-git185 changed the title Glasgow | 26-ITP-Jan| Martin McLean |Sprint 3|quotes Glasgow | 26-ITP-Jan| Martin McLean |Sprint 3|Quote Generator Mar 17, 2026
@mjm-git185 mjm-git185 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 17, 2026
<script defer src="quotes.js"></script>
</head>

<body onload="pickNewQuoteToDisplay()">
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.

Suggestion: Look up

Pros and cons between these two approaches to call a function, callback(), on page load?

  • <body onload="callback()"> in HTML code
  • windows.addEventListener("load", callback) in JS code

Comment thread Sprint-3/quote-generator/quotes.js Outdated
Comment thread Sprint-3/quote-generator/quotes.js Outdated
Comment thread Sprint-3/quote-generator/quotes.js Outdated
Comment thread Sprint-3/quote-generator/quotes.js Outdated
Comment thread Sprint-3/quote-generator/quotes.js Outdated
Comment on lines +11 to +12
document.getElementById("quote").innerHTML = "'" + quoteForDisplay + "'";
document.getElementById("author").innerHTML = ":-" + authorForDisplay;
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.

Suggestion: Look up

The differences between using .innerHTML, innerText, and textContent to set text content of an HTML element.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 26, 2026
@mjm-git185 mjm-git185 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Instead of placing all the "run on load' code in multiple places:
(1) This function call:
<body onload="pickNewQuoteToDisplay()">

and
(2) Code that setup the event listener:

  .getElementById("new-quote")
  .addEventListener("click", pickNewQuoteToDisplay);

can you practice placing all the "run on load" code inside a function?
Doing so can 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
});

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
@mjm-git185
Copy link
Copy Markdown
Author

i have made the change to the setUp on load it seems far more readable like this thanks

@mjm-git185 mjm-git185 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
@cjyuan
Copy link
Copy Markdown
Contributor

cjyuan commented Mar 26, 2026

Changes look good. Well done.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants