Skip to content

Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 3 | Quote Generator#1119

Open
mahmoudshaabo1984 wants to merge 1 commit intoCodeYourFuture:mainfrom
mahmoudshaabo1984:quote-generator
Open

Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 3 | Quote Generator#1119
mahmoudshaabo1984 wants to merge 1 commit intoCodeYourFuture:mainfrom
mahmoudshaabo1984:quote-generator

Conversation

@mahmoudshaabo1984
Copy link
Copy Markdown

Hello Reviewers / CodeYourFuture Team,

I have completed the Quote Generator App project for Sprint 3. I am excited to share that I have implemented both the mandatory requirements and the advanced stretch goal (Auto-play feature).

🎯 Acceptance Criteria Met:

  • Page Load: A random quote and its author are displayed immediately when the app loads.
  • Manual Update: Clicking the 'New Quote' button successfully displays a new random quote and author.
  • Stretch Goal (Auto-play): Added an Auto-play checkbox. When toggled ON, the quote updates automatically every 5 seconds, and the UI displays "auto-play:ON". When toggled OFF, the timer stops and displays "auto-play:OFF".

💻 Technical Implementation Details:

  • Utilized the pickFromArray() function to safely retrieve random quote objects.
  • Implemented setInterval and clearInterval to manage the auto-play timer logic without memory leaks.
  • Ensured the HTML structure is accessible. I specifically used the aria-live="polite" attribute on the quote container so that screen readers announce the new quotes automatically without interrupting the user.
  • All Jest tests (npm test) are passing successfully.

I am really enjoying working with the DOM API and asynchronous timers. I look forward to your review and feedback!

Best regards,
Mahmoud Shaabo

@mahmoudshaabo1984 mahmoudshaabo1984 changed the title Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 3 | Quote Generator Appfeat: complete mandatory and stretch goals for quote generator with a… Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 3 | Quote Generator Mar 27, 2026
@mahmoudshaabo1984
Copy link
Copy Markdown
Author

Hi @cjyuan,

I have just opened my Pull Request for the Sprint 3 project: the Quote Generator App.

I am happy to share that I have completed all the mandatory requirements, and I also implemented the stretch goal (the auto-play feature using setInterval and clearInterval).

I made sure to structure the HTML securely and used the aria-live attribute to ensure the auto-updating quotes are fully accessible for screen readers. All tests are passing successfully.

I am looking forward to your review and any feedback you might have!

Thank you,
Mahmoud

@mahmoudshaabo1984 mahmoudshaabo1984 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 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 well written and organised. Well done.

Comment on lines +17 to +22
// Listen for a click on the button, then run displayQuote
newQuoteButton.addEventListener("click", displayQuote);

// Run displayQuote once when the page loads
displayQuote();
// --- Auto-play Feature (Stretch Goal) ---
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.
You could consider placing them 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
});

Comment on lines +24 to +46
// 1. Get the checkbox and status elements from HTML
const autoPlayCheckbox = document.getElementById("auto-play-checkbox");
const autoPlayStatus = document.getElementById("auto-play-status");

// 2. Create a variable to hold the timer ID (so we can stop it later)
let autoPlayInterval;

// 3. Create a function to turn auto-play ON or OFF
function toggleAutoPlay() {
// Check if the checkbox is checked
if (autoPlayCheckbox.checked === true) {
// Turn ON: update text and start the timer (5000 milliseconds = 5 seconds)
autoPlayStatus.textContent = "auto-play:ON";
autoPlayInterval = setInterval(displayQuote, 5000);
} else {
// Turn OFF: update text and stop the timer
autoPlayStatus.textContent = "auto-play:OFF";
clearInterval(autoPlayInterval);
}
}

// 4. Listen for any "change" (check/uncheck) on the checkbox
autoPlayCheckbox.addEventListener("change", toggleAutoPlay);
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.

All this code is to implement the "auto-play timer" stretch feature, and you did good in placing all related code in one place.

If you are interested in exploring keeping the code modularised (which is an important skill for managing large application), try looking up "JavaScript ES Module" next.

@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 Mar 27, 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