File tree Expand file tree Collapse file tree
Sprint-2/3-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,17 +28,14 @@ console.log(`£${pounds}.${pence}`);
2828
2929// Answers: In line 1, a variable "penceString" was created holding the value "399p"
3030
31- // In line 3-6, Another variable "penceStringWithoutTrailingP" was created to remove the trainling "p".
32- // That is, taking off the "p" in '399p' leaving it at just "399".
33-
34- // 3-6. substring(0, penceString.length - 1):
31+ // 3-6. substring(0, penceString.length - 1):
3532// the first argument is the start index, so 0 means the first character
3633// penceString.length is 4 because there are 4 characters, at indexes 0 to 3
3734// the second argument is the end index and it is exclusive, it stops just before that position
3835// length - 1 is 3, so it stops before index 3, dropping the "p" and leaving "399"
3936
40- // Line 8 a variable "paddedPenceNumberString" was created and a function padStart(3, "0")
41- // was used to ensure the value of the variable remains at 3 and to be filled with "0" at the beginning if the value is less 3
37+ // 8. padStart(3, "0") pads the start until the string is at least 3 characters long
38+ // "399" is already 3, so nothing gets added here
4239
4340// Line 9-12 created a variable "pounds" and used the subString(0, paddedPenceNumberString.length - 2 )
4441// to start count from 0 of the "penceStringWithoutTrailingP" value which is 399.
You can’t perform that action at this time.
0 commit comments