Skip to content

Commit d3a6646

Browse files
authored
Enhance comments for pence to pounds conversion
Added comments to explain the steps for converting pence to pounds.
1 parent d899f9a commit d3a6646

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ console.log(`£${pounds}.${pence}`);
2525

2626
// To begin, we can start with
2727
// 1. const penceString = "399p": initialises a string variable with the value "399p"
28+
// 2. penceString.substring(0, penceString.length - 1): Removes the final character ("p") from the string.
29+
// 3. padStart(3, "0"): Makes sure the number contains at least 3 characters. If it has fewer than 3 characters, zeros are added to the beginning.
30+
// 4. substring(0, paddedPenceNumberString.length - 2): Gets everything except the final two characters. The final two characters represent the pence.
31+
// 5. substring(paddedPenceNumberString.length - 2): Gets the final two characters of the string.
32+
// 6. console.log(...): Combines the pounds and pence into a price format.

0 commit comments

Comments
 (0)