Skip to content

Commit 721fe57

Browse files
committed
finishing touch
1 parent d0c0bd7 commit 721fe57

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ 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+
29+
// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): This line removes the trailing 'p' from the string.
30+
31+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): This line puts the string into a 3 character string padding with zeros.
32+
33+
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): This line takes out the pounds part of the string.
34+
35+
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): This line takes out pence part and pads it to 2 characters.
36+
37+
// 6. console.log(`£${pounds}.${pence}`): This line prints the final results.

0 commit comments

Comments
 (0)