Skip to content

London | ITP-May-2025 | Seddiq Azam | Module-Structuring-and-Testing-Data | Sprint-1 #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

sedazam
Copy link

@sedazam sedazam commented Jun 11, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.
This pull request concerns the sprint-1 tasks for the module.
Implemented various functions to generate random integers within a specified range, minimum, and maximum.
used Math.random() scaled to the range size, with Math.floor() to ensure an integer results.
identified common errors in the code

Questions

Ask any questions you have for your reviewer.

@sedazam sedazam requested a review from Copilot June 11, 2025 20:10
@sedazam sedazam added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Participant to add when requesting review labels Jun 11, 2025
Copilot

This comment was marked as outdated.

@sedazam sedazam requested a review from Copilot June 11, 2025 20:13
Copilot

This comment was marked as outdated.

@cjyuan cjyuan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jun 21, 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.

Explanation is clear. Well done.

I only have a challenge question for you.

Comment on lines +44 to +49
// 5. const pence = paddedPenceNumberString
// .substring(paddedPenceNumberString.length - 2)
// .padEnd(2, "0");
// This line extracts the last two digits, which represent the pence.
// The `.padEnd(2, "0")` ensures that even if the pence value is only one digit (e.g., "5"), it becomes two digits (e.g., "05").
// So "5p" would correctly display as "£0.05" instead of "£0.5".
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we expect this program to work as intended for any valid penceString if we deleted .padEnd(2, "0") from the code?
In other words, do we really need .padEnd(2, "0") in this script?

Copy link
Author

Choose a reason for hiding this comment

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

.padEnd(2, "0") ensures that the pence value always has two digits, by padding with a zero on the right if necessary.
if we remove .padEnd(2, "0"), the value "5p" will be displayed as "£0.5"
.substring(paddedPenceNumberString.length - 2) will return just "5" when the input is only one digit long.
This leads to incorrect currency formatting, since "£0.5" means 50p, not 5p.

Copy link
Contributor

@cjyuan cjyuan Jun 23, 2025

Choose a reason for hiding this comment

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

Have you tried verifying your expectations by executing the script without .padEnd(2, "0") using different values of penceString?

Copy link
Author

Choose a reason for hiding this comment

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

I tested the code with different values. When I used "999p", the output was "£9.99" — both with and without .padEnd(2, "0").

After doing some research, I found that the line:

.substring(paddedPenceNumberString.length - 2)

returns the last two characters of the string. In this case, it correctly returns "99", which is already two characters long.

Therefore, using .padEnd(2, "0") is unnecessary in this situation.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jun 21, 2025
@sedazam sedazam added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jun 23, 2025
@sedazam sedazam requested a review from Copilot June 23, 2025 17:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds detailed documentation and explanatory comments across several modules while fixing minor errors in variable declarations and string methods. Key changes include expanded answers on JavaScript console behavior and user prompts, improved inline explanations for number formatting and error debugging, and corrections to variable declarations in error examples.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Sprint-1/4-stretch-explore/objects.md Added step-by-step answers about the Chrome DevTools Console.
Sprint-1/4-stretch-explore/chrome.md Expanded the walkthrough and explanation of prompting in Chrome.
Sprint-1/3-mandatory-interpret/3-to-pounds.js Detailed commentary on handling currency string formatting.
Sprint-1/3-mandatory-interpret/2-time-format.js Extended answers regarding time formatting with suggestions.
Sprint-1/3-mandatory-interpret/1-percentage-change.js Added explanations and highlighted a syntax error fix in replaceAll.
Sprint-1/2-mandatory-errors/(1.js, 2.js, 3.js, 4.js) Fixed variable declaration issues and corrected method calls.
Sprint-1/1-key-exercises/(1-count.js, 2-initials.js, 3-paths.js, 4-random.js) Included detailed answers and updated code examples for clarity.

// This code will not display properly for movies with a duration of 0 seconds,
// as the output would appear as "0:0:0", which is not well-formatted.

// We can fix this by applying the .padStart() method to each time unit
Copy link
Preview

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

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

Consider updating the code to apply padStart for formatting hours, minutes, and seconds. This will ensure that values like '0' are displayed as '00', improving the readability of the time output.

Copilot uses AI. Check for mistakes.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jun 23, 2025
@sedazam sedazam added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jun 24, 2025
@cjyuan cjyuan added Reviewed Volunteer to add when completing a review Complete Volunteer to add when work is complete and review comments have been addressed and removed Needs Review Participant to add when requesting review Reviewed Volunteer to add when completing a review labels Jun 25, 2025
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 review comments have been addressed 📅 Sprint 1 Assigned during Sprint 1 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants