You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 1. const penceString = "399p": initialises a string variable with the value "399p"
28
+
// 2. Lines 3 to 6: extracts "399" as a string and assigns the values to penceStringWithoutTrailingP.
29
+
// It uses the substring to extract from position 0 to 3.
30
+
// 3. Line 8: padStart is used to pad the values in penceStringWithoutTrailingP with "0" from the start of the value to make up a length of 3.
31
+
// Since penceStringWithoutTrailingP already has "399" with a length of 3, no padding is done.
32
+
// 4. Line 9 to 12: substring is used to extract from paddedPenceNumberString, starting from position 0 to 1 giving 3 which is stored in the variable pounds.
33
+
// 5. Line 14 to 16: substring is used to extract from paddedPenceNumberString, starting from position 1 to the end givin "99"
34
+
// "99" is padded with "0" from the end of the value to make a length of 2 but sincw "99" already has a length of 2, no padding is done.
35
+
// "99" is assigned to the variable pence.
36
+
// 6. Line 18: uses console.log() to print the values of pounds and pence preceeded by "£" and separated by "." to give "£3.99"
0 commit comments