Skip to content

BIRMINGHAM | ITP-JAN 26 | Merve Reis | Sprint 3 | Quote Generator#1043

Open
mervereis wants to merge 2 commits intoCodeYourFuture:mainfrom
mervereis:Sprint-3-Quote-Generator
Open

BIRMINGHAM | ITP-JAN 26 | Merve Reis | Sprint 3 | Quote Generator#1043
mervereis wants to merge 2 commits intoCodeYourFuture:mainfrom
mervereis:Sprint-3-Quote-Generator

Conversation

@mervereis
Copy link
Copy Markdown

@mervereis mervereis commented Mar 18, 2026

Learners, PR Template

Self checklist

  • 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

Changelist

Created Quote Generator application.
Updated index.html file, added quote generator functionality and created styles for it.

@mervereis mervereis added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. labels Mar 18, 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.

Code is working good.

  • There is some unnecessary code you can remove to keep the code cleaner.

Comment on lines +509 to +522
btn.addEventListener("click", showQuote);

toggle.addEventListener("change", () => {
if (toggle.checked) {
statusEl.textContent = "Auto Play: ON";
interval = setInterval(showQuote, 3000);
} else {
statusEl.textContent = "Auto Play: OFF";
clearInterval(interval);
interval = null;
}
});

showQuote();
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.

Placing all the "run on load" code in one place is a good practice.
Would be even better to place the code (and the constants/variables needed locally by these 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.

@cjyuan I moved the logic what we run while page load into the setup function then I called it with eventListener as you suggest

const picked = pickFromArray(quotes);
console.log(picked);
quoteEl.textContent = picked.quote;
authorEl.textContent = "- " + picked.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.

Since "- " is part of the presentation logic, it is better to keep it in the CSS or in HTML.

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.

@cjyuan I moved the '-' part to CSS file

@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
@mervereis mervereis added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 29, 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.

Moving all the code that implements the app into setup() is not what I had in mind; some of those code are just function definitions. What I had in mind was,

... // shared constants/variables declaration

... // function definitions

function setup() {
  ... // Code that setups the callback functions

  showQuote();
}

window.addEventListener("load", setup);

No change required. Organizing code is not an easy task and what I am suggesting here is not the only way. At least you have experienced one way to organize code in a local scope.

Code looks good. Well done.

}
function showQuote() {
const picked = pickFromArray(quotes);
console.log(picked);
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.

This seems like a piece of debugging code. Best practice is to delete all unnecessary code before submitting the code for review.

@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 29, 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. Module-Data-Groups The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants