Skip to content

Conversation

@enjoy15
Copy link

@enjoy15 enjoy15 commented Oct 15, 2025

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

-Completed all excercises in Sprint-1

@enjoy15 enjoy15 added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 15, 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 very clear and answers are accurate.

I just have a few questions.


// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing
// Line 3 is an assignment statement. The = is the assignment operator, which takes the value on the right side (count + 1, which evaluates to 1) and assigns it to the variable on the left side (count), updating count's value from 0 to 1
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?

Copy link
Author

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?

@cjyuan increment



// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
//syntax error! On line 5, there's a missing comma in the replaceAll method.
Copy link
Contributor

Choose a reason for hiding this comment

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

In the function call .replaceAll(",", ""), there's a programming term for "," and "" (the values passed into the function). Could you find out what this term is?

Copy link
Author

Choose a reason for hiding this comment

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

arguments

// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): removes the trailing 'p' from the string to isolate the numeric part
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): pads the numeric string with leading zeros to ensure it is at least 3 digits long
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds portion from the padded string
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence portion and ensures it is 2 digits long
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.

No, we don't need .padEnd(2, "0") in this script. —Since padStart(3, "0") ensures the string is minimum 3 characters, and we're extracting the last 2, we'll always get exactly 2 characters. The .padEnd(2, "0") is redundant.

Comment on lines +20 to +21
-> It displays a dialog box in the browser asking the user to enter some input.
The user can type a response and click "OK" or click "Cancel".
Copy link
Contributor

Choose a reason for hiding this comment

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

What value does prompt() return? How can the program that call prompt() find out if the user clicked OK or Cancel?

Copy link
Author

Choose a reason for hiding this comment

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

The prompt() function returns different values depending on what the user does:
1. If the user types something and clicks "OK": prompt() returns a string containing whatever the user typed
◦ Even if they type nothing and click OK, it returns an empty string ""
2. If the user clicks "Cancel" (or presses ESC): prompt() returns null
The return value is either a string (including empty string "") or null. This null value is how the program knows the user clicked Cancel rather than OK.

@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 Oct 15, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Oct 16, 2025

Spot on! Great work!

In the PR description, Can you change "#Changelist" to a level-2 header in Markdown, to make it look like this?

Changelist

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 16, 2025
@enjoy15
Copy link
Author

enjoy15 commented Oct 16, 2025

@cjyuan I have changed "#Changelist" to a level-2 header in Markdown.
Thank you so much for your review.

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. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants