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: from index 0, to length of string - 1 (4-1=3). (0,3) we get the string from index 0 to index 2 which removes the p at the end.
29
+
// 3. const paddedPenceNumberString: if length < 3, pad start of string with "0". since it is we just get 399.
30
+
// 4. const pounds: take string from index 0 to length of string - 2 (3-2=1). (0,1) we get the 1st index "3".
31
+
// 5. .substring(): length = 3. (3-2=1). (1,end of string). this gives us 99
32
+
// 6. .padEnd(): if previous length of string < 2: pad end with "0"
33
+
// 7. console.log() basically just prints pounds and pence as the proper format (£"pound"."pence") using string literals
34
+
// NB: padding is for a safety measure if the inputs were shorter.
0 commit comments