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
+
// to begin we can start with
30
+
//1- const penceSring= "399p": initialises a string variable with the value "399p"
31
+
//2- const penceStringWithoutTrailingP= a string value "399" is reassigned to penceStringWithoutTrailingP by removing the last character "p" from penceString using the substring method
32
+
//3- const paddedPenceNumberString= declared new variable, padStart ensure any argument passed is at least 3 characters long by adding leading zeros if necessary
33
+
//4- line 9 a new variable pence is declared and its value comes from the padded string by removing the last two characters which represent the pence.
34
+
//5- line 14 const pence= declared variable and the variable is the result after extracting the last two characters from paddedPenceNumberString using substring method and padEnd method is used to ensure that the pence value is always two digits long by adding trailing zeros if necessary
35
+
// from the pence string and pads it to two characters to have two digits number.
36
+
//6- line 18: console.log (`£${pounds}.${pence}`): returns money amount combing pounds and pence along with the £ symbol
0 commit comments