Skip to content

Commit c629a91

Browse files
committed
Clarified comment on the extraction of the pence part in 3-to-pounds.js
1 parent c9494b4 commit c629a91

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ console.log(`£${pounds}.${pence}`);
2828
//2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): removes the trailing "p" from the penceString to get just the numeric part of the price in pence.
2929
//3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): Ensures that the string always has 3 numbers by adding zeroes to the string if less than 3 characters.
3030
//4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): Extracts the pounds part of the string. The last two digits are pence but the first is pounds.
31-
//5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): Extracts the pence part of the string and ensures its always two digits by adding zeroes when needed. Although .padEnd(2,"0") is not needed in this case as the string will always be two digits.
31+
//5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): Extracts the pence part of the string and ensures its always two digits by adding zeroes when needed. Although .padEnd(2,"0") is not needed in this case as the string will always be two digits because the length of the string is always 3 as ensured by .padStart(3,"0") on line 3.
3232
//6. console.log(`£${pounds}.${pence}`): Outputs the final price in pounds and pence format.

0 commit comments

Comments
 (0)