File tree Expand file tree Collapse file tree
Sprint-1/3-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,3 +25,16 @@ console.log(`£${pounds}.${pence}`);
2525
2626// To begin, we can start with
2727// 1. const penceString = "399p": initialises a string variable with the value "399p"
28+
29+ // Answers
30+ // 1) variable const penceStringWithoutTrailingP stores the value of only the pennies part without the p.
31+ // This is done first with penceString.length -1 removes the last index of pence string (p).
32+ // Then penceString.substring(0) returns the characters from 0 to 2 of the indexes(399)
33+
34+ // 2) paddedPenceNumberString adds 0 at the beginning until the string is 3 characters long to penceStringWithoutTrailingP variable
35+
36+ // 3) pounds stores 3 by first paddedPenceNumberString.length - 2 removing index 1 and 2. Then paddedPenceNumberString.substring(0) returning index 0.
37+
38+ // 4) pence store the pennies first .length starting from index 1 then padEnd adding 0 to characters that less than 2 counts.
39+
40+ // 5) console.log prints out the final result adding a £ sign at the beginning and a . between pounds and pence.
You can’t perform that action at this time.
0 commit comments