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
// You need to do a step-by-step breakdown of each line in this program
24
24
// Try and describe the purpose / rationale behind each step
25
25
26
-
// To begin, we can start with
27
-
// 1. const penceString = "399p": initialises a string variable with the value "399p"
26
+
27
+
//3. This line truncates the string by index, excluding the last character, without the letter p.
28
+
//8. This line is needed in case the variable length is shorter than 3 characters. If the variable value is less than 1 pound, calling the padStart() function guarantees that there are 3 characters so that we can later convert pence to the 0.00 format (we will add the decimal point later).
29
+
//9. saves the entire string except for the last 2 characters, i.e. the number of pounds
30
+
//14. saves the value of the last two characters, i.e. the number of pence
31
+
//18. this line outputs the final value in the standard format £0.00
0 commit comments