Skip to content

Commit f86c338

Browse files
committed
Complete pence to pounds interpretation
1 parent cec8b9b commit f86c338

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ 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 = ...: removes the final "p" from "399p", leaving "399"
30+
// 3. padStart(3, "0"): makes sure the pence string has at least 3 characters by adding zeros to the beginning if needed.
31+
// 4. const pounds = ...: takes all the characters except the last two, giving the pounds part of the price.
32+
// 5. const pence = ...: takes the last two characters as the pence part and makes sure it has two characters.
33+
// 6. console.log(`£${pounds}.${pence}`): displays the final price in pounds and pence format.

0 commit comments

Comments
 (0)