Skip to content

Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 1 | Module Structuring and Testing Data#976

Closed
mahmoudshaabo1984 wants to merge 2 commits into
CodeYourFuture:mainfrom
mahmoudshaabo1984:coursework/sprint-1
Closed

Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 1 | Module Structuring and Testing Data#976
mahmoudshaabo1984 wants to merge 2 commits into
CodeYourFuture:mainfrom
mahmoudshaabo1984:coursework/sprint-1

Conversation

@mahmoudshaabo1984

Copy link
Copy Markdown

I have completed the coursework for Sprint 1.

Work done:

  • Fixed all bugs in the 2-mandatory-errors directory.
  • Provided detailed interpretations and answered all questions in the 3-mandatory-interpret directory.
  • Ensured all variable naming and scoping issues were resolved.

Learners, PR Template

  • 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

@mahmoudshaabo1984 mahmoudshaabo1984 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 17, 2026

@cjyuan cjyuan left a comment

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.

Code is quite well written. I mainly have some questions and suggestions.

Comment thread Sprint-1/1-key-exercises/1-count.js Outdated

// 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
// The code adds 1 to the count variable.

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.

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 thread Sprint-1/1-key-exercises/4-random.js Outdated
// Try logging the value of num and running the program several times to build an idea of what the program is doing

console.log(num);
// num represents a random integer between 1 and 100.

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.

Phrases like "a number between X and Y" are not precise enough in a program specification, because they do not clearly state whether the endpoints X and Y are included.

We can also use the concise and precise interval notation to describe a range of values.

  • [, ] => inclusion
  • (, ) => exclusion

For example, [1, 10) means, all numbers between 1 and 10, including 1 but excluding 10.

Comment thread Sprint-1/2-mandatory-errors/3.js Outdated
Comment on lines 1 to 2
const cardNumber = 4533787178994213;
const cardNumber = "4533787178994213";
const last4Digits = cardNumber.slice(-4);

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.

Suppose you were not allowed to modify the statement const cardNumber = 4533787178994213;
(that is, keep the variable's value unchanged).
How would you modify the code (through type conversion) so that you can still use .slice(-4) to extract the last 4 digits from the given number.

Comment on lines +15 to +16
// 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?

// replaceAll might not work in older Node versions

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.

Can you describe why the original code on line 5 does not work? Here is the code:
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));

Note: There is an easier way to fix the original code than replacing replaceAll() by replace().

Comment on lines +34 to +35
// 5. const pence = ...
// It extracts the last two characters to represent the pence part and ensures it has two digits.

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.

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?

@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 Feb 18, 2026
…m, interval notation, type conversion, fix syntax error explanation, and clarify padEnd redundancy
@mahmoudshaabo1984

Copy link
Copy Markdown
Author

Hi @cjyuan,

Thank you for reviewing my code and for your detailed feedback. I've updated all five files based on your suggestions:

  1. 1-count.js: Updated the comment to use the correct programming term — this is an increment operation.

  2. 4-random.js: Replaced "between 1 and 100" with proper interval notation: [1, 100]. I also added a step-by-step breakdown showing how the expression evaluates to this range.

  3. 3.js (mandatory-errors): Reverted cardNumber back to a number (without quotes) and used String(cardNumber).slice(-4) for type conversion instead of modifying the original value.

  4. 1-percentage-change.js: Corrected my explanation — the real error was a missing comma between the two arguments in replaceAll("," ""). The fix is simply adding the comma: replaceAll(",", "").

  5. 3-to-pounds.js: After testing with different inputs like "5p", "50p", and "399p", I concluded that .padEnd(2, "0") is actually not needed in this script because .padStart(3, "0") already guarantees at least 3 characters, so .substring() will always extract exactly 2 characters for the pence part.

Please let me know if there is anything else I should improve. I appreciate the feedback — it helped me understand these concepts more deeply.

Best regards,
Mahmoud

@cjyuan

cjyuan commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for answering all my questions, and they are all spot on! Excellent job!

@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 Feb 19, 2026
@mahmoudshaabo1984 mahmoudshaabo1984 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 19, 2026
@cjyuan

cjyuan commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Sorry, I beat you on the label. :P

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 19, 2026
@illicitonion

Copy link
Copy Markdown
Member

Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it.

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