Skip to content

Commit f5624ee

Browse files
committed
removed .padEnd(2, 0) from 3-to-pound.js
1 parent 7648cf0 commit f5624ee

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ const pounds = paddedPenceNumberString.substring(
1313
);
1414

1515
const pence = paddedPenceNumberString
16-
.substring(paddedPenceNumberString.length - 2)
17-
.padEnd(2, "0");
16+
.substring(paddedPenceNumberString.length - 2);
1817

1918
console.log(${pounds}.${pence}`);
2019

@@ -29,6 +28,6 @@ console.log(`£${pounds}.${pence}`);
2928
2. const penceStringWithoutTrailingP = This stores the substring of penceString by extracting all characters except the final p. It takes the substring from index 0 up to (but not including) the last character p, so "399p" becomes "399". This removes the unit symbol so only the numeric portion remains.
3029
3. const paddedPenceNumberString= This stores the value of penceStringWithoutTrailingP, padded to a total length of 3 characters by adding leading zeros where necessary. This guarantees there are always enough digits to separate pounds and pence correctly.
3130
4. const pounds= Stores the substring of paddedPenceNumberString from index 0 to the last 2 index. These leading digits represent the pound portion of the amount.
32-
5. const pence= Extracts the final two digits of the padded string to represent the pence portion. padEnd(2, "0") ensures that the pence value always contains exactly two digits.
31+
5. const pence= Extracts the final two digits of the padded string to represent the pence portion.
3332
6. console.log(`£${pounds}.${pence}`); logs the value of pounds and pence into a formatted currency string using template literals
3433
*/

0 commit comments

Comments
 (0)