@@ -27,21 +27,22 @@ console.log(`£${pounds}.${pence}`);
2727// 1. const penceString = "399p": initialises a string variable with the value "399p"
2828
2929// Answers: In line 1, a variable "penceString" was created holding the value "399p"
30+
3031// In line 3-6, Another variable "penceStringWithoutTrailingP" was created to remove the trainling "p".
3132// That is, taking off the "p" in '399p' leaving it at just "399".
3233
33- // Line 3-6 used the function substring(0, penceString.lrength - 1) to cut out the "p" in the "penceString" variable.
34+ // Also, line 3-6 used the function substring(0, penceString.lrength - 1) to cut out the "p" in the "penceString" variable.
3435// By starting count fron 0 (beginnning) of "399p".
3536// "Using penceString.lenght - 1" to check the length of the value in the variable penceString = "399p" (4),
36- // And deducting 1 from the value (399p - 1) leaving the value at "399"
37+ // And deducting 1 from the value (4 - 1), because length - 1 subtract 1 from the character/value count 4. leaving the value at "399"
3738
3839// Line 8 a variable "paddedPenceNumberString" was created and a function padStart(3, "0")
3940// was used to ensure the value of the variable remains at 3 and to be filled with "0" at the beginning if the value is less 3
4041
4142// Line 9-12 created a variable "pounds" and used the subString(0, paddedPenceNumberString.length - 2 )
4243// to start count from 0 of the "penceStringWithoutTrailingP" value which is 399.
4344// It further removed the last two number in the value by checking the length of the value with "paddedPenceNumberString.length"
44- // And subtracting 2 (399 - 2), cutting out 99 and leaving the value to remain 3.
45+ // And subtracting 2 (3 - 2), because length - 2 subtract 2 from the character/value count. Cutting out 99 and leaving the value to remain 3.
4546
4647// Line 14-16 created a variable "pence", using the subString(paddedPenceNumberString.length - 2)
4748// to check the length of the value of the variable "paddedPenceNumberString" which remain 399 from line 8
0 commit comments