@@ -2,13 +2,13 @@ const penceString = "399p";
22
33const penceStringWithoutTrailingP = penceString . substring (
44 0 ,
5- penceString . length - 1
5+ penceString . length - 1 ,
66) ;
77
88const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
99const pounds = paddedPenceNumberString . substring (
1010 0 ,
11- paddedPenceNumberString . length - 2
11+ paddedPenceNumberString . length - 2 ,
1212) ;
1313
1414const pence = paddedPenceNumberString
@@ -26,7 +26,7 @@ console.log(`£${pounds}.${pence}`);
2626// To begin, we can start with
2727
2828// 1. const penceString = "399p": initialises a string variable with the value "399p"
29- // 3. penceStringWithoutTrailingP is created using substring() on penceString. The purpose is to remove the trailing "p"..
29+ // 3. penceStringWithoutTrailingP is created using substring() on penceString. The purpose is to remove the trailing "p"..
3030// 4. value for substring method to start from which is beginning of the string.
3131// 5. penceString variable uses argument of .length to -1 (p) from the value, 399p becomes 399.
3232// 6. substring method closure
@@ -35,7 +35,7 @@ console.log(`£${pounds}.${pence}`);
3535//10. value for substring method which is beginning of the string.
3636//11. paddedPenceNumberString variable is using length argument and deduct 2 out of length of the string 399 become 3 as pounds.
3737//12. Closes the substring method.
38- //14. pence variable created from paddedPenceNumberString
38+ //14. pence variable created from paddedPenceNumberString
3939//15. substring method called which value of is in the parenthesis (variable length -2 characters)
4040//16. method padEnd is called that contains at least 2 character and adds 0 at the end if needed.
4141//18. we log £3.99 in the console.
0 commit comments