Skip to content

Conversation

@Fithi-Teklom
Copy link

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

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Sprint-3) doesn't match expected format (example: 'Sprint 2', without quotes)

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@Fithi-Teklom Fithi-Teklom changed the title Manchester| 25-ITP-Sep| Fithi Teklom| Sprint-3 | Quote Generator App Manchester| 25-ITP-Sep| Fithi Teklom| Sprint 3 | Quote Generator App Dec 6, 2025
@Fithi-Teklom Fithi-Teklom added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 11, 2025
Copy link
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 looks good.
I just have some suggestions.

Comment on lines 46 to 65
let autoPlayInterval = null;

const toggle = document.getElementById("auto-play-toggle");
const statusText = document.getElementById("auto-status");

toggle.addEventListener("change", () => {
if (toggle.checked) {
statusText.textContent = "auto-play:ON";

// Change every 5 seconds (easy for testing)
autoPlayInterval = setInterval(() => {
pickQuoteAndAuthor();
}, 5000);

pickQuoteAndAuthor(); // Change immediately
} else {
statusText.textContent = "auto-play:OFF";
clearInterval(autoPlayInterval);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider wrapping all the code and variables needed to support auto-play inside a function as:

function setupAutoPlay() {
  // JavaScript support closure. So even after this function call returns, the 
  // inner function can still access these variables.
  let autoPlayInterval = null;
  const toggle = document.getElementById("auto-play-toggle");
  const statusText = document.getElementById("auto-status");

  toggle.addEventListener("change", () => {
     ...
  });
}

and then call the function in the onload event listener as

window.addEventListener("load", () => {

  button.addEventListener("click", displayRandomQuote);

  // By placing the setup code in a separate function, it makes finding out "what operations are
  // performed once on page load" easier.
  setupAutoPlay();

  displayRandomQuote();
});

Comment on lines +24 to 39
const quoteEl = document.getElementById("quote");
const authorEl = document.getElementById("author");
const button = document.getElementById("new-quote");

// Generate a random quote using Math.random (required for tests)
function getRandomQuote() {
const index = Math.floor(Math.random() * quotes.length);
return quotes[index];
}

// Put the quote + author into the DOM
function displayRandomQuote() {
const q = getRandomQuote();
quoteEl.textContent = q.quote;
authorEl.textContent = q.author;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider declaring top-level variables and defining functions outside of the onload event listener. Doing so could make finding out "what operations are performed once on page load" easier.

@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. labels Dec 12, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Dec 12, 2025

You missed leaving a changelist section in the PR description.

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