Skip to content

London | May-2025 | Mohamed Ibrahim | Sprint-1#521

Closed
sidicamoli wants to merge 19 commits intoCodeYourFuture:mainfrom
sidicamoli:coursework/sprint-1
Closed

London | May-2025 | Mohamed Ibrahim | Sprint-1#521
sidicamoli wants to merge 19 commits intoCodeYourFuture:mainfrom
sidicamoli:coursework/sprint-1

Conversation

@sidicamoli
Copy link

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

  • Commented out instruction lines in Sprint-1/2-mandatory-errors/0.js as requested

Questions

None for now, thanks!

@sidicamoli sidicamoli added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 13, 2025
@cjyuan cjyuan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 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 few suggestions and questions.

Comment on lines 7 to 8
// Line 3 takes the current value of count (0), adds 1 to it, and assigns the result (1) back to count.
// The = operator is used for assignment — it sets the variable to a new value. No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Operation like count = count + 1 is very common in programming, and there is a programming term describing such operation.

Can you find out what one-word programming term describes the operation on line 3?

Comment on lines 10 to 11
1. Math.random()
Returns a random decimal number between 0 (inclusive) and 1 (exclusive).
Copy link
Contributor

Choose a reason for hiding this comment

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

We can also use the concise and precise interval notation to describe a range of values.
For example, we can say, "Math.random() returns a random number in the interval [0, 1)"

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! I understand now that interval notation shows the range of values. For example, Math.random() returns a number between 0 (included) and 1 (not included), written as [0, 1). That makes it easier to see the limits clearly

// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1); Removes the trailing "p" character from the string by slicing off the last character.
// 3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); Ensures the number is at least 3 characters long by adding leading zeros if necessary (e.g., "9" becomes "009").
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); Extracts the pound portion by taking all but the last two characters (e.g., from "399", this becomes "3").
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); Extracts the last two characters as pence (e.g., from "399", this gives "99"). .padEnd(2, "0") ensures we still get two digits (e.g., from "3" it would become "30").
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?

Comment on lines +21 to +22
A; It returns the text the user types in, and stores it in the variable `myName`.
For example, if I typed "Alice", then `myName` would be "Alice".
Copy link
Contributor

Choose a reason for hiding this comment

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

If we were writing a program that uses prompt() to ask for an input value, how could
the program check if the user clicked "OK" or "Cancel"?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jun 21, 2025
@sidicamoli sidicamoli added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 22, 2025
@sidicamoli
Copy link
Author

Updated Sprint-1 after review:

• Improved explanation for count = count + 1 using the correct term.

• Fixed conflict and explained random.js step-by-step with interval notation.

• Refined comments in 3-to-pounds.js and removed .padEnd() as it wasn’t needed.

• Added details in chrome.md about how prompt() works and how to check for cancel/ok.

Thanks to CJ Yuan for the helpful feedback!

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.

Changes look good.

Leaving responses directly in the comment threads makes it easier to track the discussion. You can try the approach in future PRs.
image

If the user clicks "Cancel", prompt() returns null.

Example:
if (myName = null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Equality operator is ==

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I’ve understood it clearly!

@cjyuan cjyuan 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 Jun 22, 2025
@cjyuan cjyuan added the Complete Volunteer to add when work is complete and all review comments have been addressed. label Jun 22, 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 all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants