Skip to content

London | 26-ITP-Jan | Alex Okorefe | Sprint 1 | Coursework#1010

Open
Alex-Os-Dev-Lab wants to merge 12 commits intoCodeYourFuture:mainfrom
Alex-Os-Dev-Lab:coursework/sprint-1
Open

London | 26-ITP-Jan | Alex Okorefe | Sprint 1 | Coursework#1010
Alex-Os-Dev-Lab wants to merge 12 commits intoCodeYourFuture:mainfrom
Alex-Os-Dev-Lab:coursework/sprint-1

Conversation

@Alex-Os-Dev-Lab
Copy link

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 the JavaScript tasks

Questions

No questions for now

@Alex-Os-Dev-Lab Alex-Os-Dev-Lab added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
Comment on lines +19 to +22
// 2. Then Math.random() is called, which generates a random decimal number between 0 and 1.
// 3. The result of Math.random() is multiplied by the result of step 1, giving us a random decimal number between 0 and 100.
// 4. Math.floor() is then called on the result of step 3, which rounds it down to the nearest whole number, giving us a random integer between 0 and 99.
// 5. Finally, the minimum value (1) is added to the result of step 4, giving us a random integer between 1 and 100.
Copy link
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 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 on lines +1 to 2
const cardNumber = "4533787178994213";
const last4Digits = cardNumber.slice(-4);
Copy link
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 +16 to +17
// Function calls are determined by the presence of parentheses "()" after a function name.
// Therefore in this file, there are 6 function calls:
Copy link
Contributor

Choose a reason for hiding this comment

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

Which 6? There should be less than 6 function calls in the code.

Comment on lines +109 to +119
// f. Therefore, if the paddedPenceNumberString variable has a length of less than 2 characters, the padEnd method will add "0" characters
// to the end of the string until it reaches a total length of 2 characters.
// In this case, since paddedPenceNumberString is "399" which has a length of 3 characters,
// the substring method will extract the last two characters "99"
// and then the padEnd method will not add any padding since the length of the resulting string is already 2 characters.
// therefore pence will be "99"

// g. if penceString = "9p" ; const penceStringWithoutTrailingP = "9" ; const paddedPenceNumberString = "009" ;
// const pounds = "0" ; const pence = "09" because the substring method will extract the last two characters "09"
// and then the padEnd method will not add any padding since the length of the resulting string is already 2 characters.
// therefore pence will be "09"
Copy link
Contributor

Choose a reason for hiding this comment

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

Very thorough analysis.

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 Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants