Skip to content

Commit cdbf949

Browse files
committed
All done here in this exercise
1 parent 7bc75f1 commit cdbf949

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ 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": initialises a string variable with the value "399p".
28+
// 2. line (3) it returns a substring from the given string, it takes penceString and returns the substring that start with index 0 ends one character before the end we have 399p it returns 399.
29+
// 3. line (8) we have the string 399 that's 3 characters means we can split it to pounds.
30+
// 4. line (9) We have the start and the end. We start at 0, then end two characters before the string’s end, because the last two characters represent pence.
31+
// 5. line (14) This takes the last two characters of the string, which represent the pence portion of the price.it also Extracts the pence digits safely and makes sure it’s always two digits, even if the original number was small.
32+
// 6. line (18) This prints the final price to the console in pounds and pence, using the pounds and pence variables to show it like £3.99.
33+

0 commit comments

Comments
 (0)