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
+
29
+
// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): This line removes the trailing 'p' from the string.
30
+
31
+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): This line puts the string into a 3 character string padding with zeros.
32
+
33
+
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): This line takes out the pounds part of the string.
34
+
35
+
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): This line takes out pence part and pads it to 2 characters.
36
+
37
+
// 6. console.log(`£${pounds}.${pence}`): This line prints the final results.
0 commit comments