Skip to content

Commit be6a3b0

Browse files
committed
completed scheduled tasks
1 parent ee63ed9 commit be6a3b0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ console.log(`£${pounds}.${pence}`);
2424
// Try and describe the purpose / rationale behind each step
2525

2626
// To begin, we can start with
27-
// 1. const penceString = "399p": initialises a string variable with the value "399p"
27+
// 1. const penceString = "399p": initializes a string variable with the value "399p"
28+
// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): removes the trailing 'p' from the string
29+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): ensures the string has at least 3 characters by padding with leading zeros if necessary
30+
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds part of the string (all but the last two characters)
31+
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence part (the last two characters) and pads with trailing zeros if necessary
32+
// 6. console.log(`£${pounds}.${pence}`): formats and prints the final price in pounds and pence format

0 commit comments

Comments
 (0)