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. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): Removes the "p" from the end.
29
+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): Makes the string at least 3 letters long by adding "0"s to the front.
30
+
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): Grabs everything except the last two digits to find the "pound" amount.
31
+
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): Grabs exactly the last two digits.
32
+
// 6. console.log(`£${pounds}.${pence}`): Combines the pounds and pence with a decimal point and a "£" symbol.
0 commit comments