Skip to content

Commit 304536e

Browse files
committed
update - Convert pence to pounds
1 parent f142f39 commit 304536e

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ console.log(`£${pounds}.${pence}`);
2626
// To begin, we can start with
2727
// 1. const penceString = "399p": initialises a string variable with the value "399p"
2828

29-
1. const penceString = "399p" // Stores "399p" in a variable called penceString so the program can work with the price.
30-
2. const penceStringWithoutTrailingP = penceString.substring(
31-
0,
32-
penceString.length - 1
33-
); // Removes the "p" from the end of "399p", leaving "399"
34-
3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
29+
// 1. const penceString = "399p" // Stores "399p" in a variable called penceString so the program can work with the price.
30+
// 2. const penceStringWithoutTrailingP = penceString.substring(
31+
// 0,
32+
// penceString.length - 1);
33+
// Removes the "p" from the end of "399p", leaving "399"
34+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
3535
//Adds a "0" at the start if there are less than 3 digits.
36-
4. const pounds = paddedPenceNumberString.substring(
37-
0,
38-
paddedPenceNumberString.length - 2); //gets the digits before the last two to find the pounds.
36+
// 4. const pounds = paddedPenceNumberString.substring(
37+
// 0,
38+
// paddedPenceNumberString.length - 2); //gets the digits before the last two to find the pounds.
3939

40-
5. const pence = paddedPenceNumberString
41-
.substring(paddedPenceNumberString.length - 2)
42-
.padEnd(2, "0"); //gets the last two digits to find the pence.
40+
// 5. const pence = paddedPenceNumberString
41+
// .substring(paddedPenceNumberString.length - 2)
42+
// .padEnd(2, "0"); //gets the last two digits to find the pence.
4343

44-
6. console.log(`£${pounds}.${pence}`); //Combines the pounds and pence and print the final price as £3.99
44+
// 6. console.log(`£${pounds}.${pence}`); //Combines the pounds and pence and print the final price as £3.99

0 commit comments

Comments
 (0)