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 @@ -25,3 +25,23 @@ 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+
30+ // 1. const penceString = "399p"
31+ // Initialises a string variable with the value "399p"
32+
33+ // 2. penceString.substring(0, penceString.length - 1)
34+ // Removes the final "p", leaving "399"
35+
36+ // 3. penceStringWithoutTrailingP.padStart(3, "0")
37+ // Makes the string 3 characters long by adding "0" at the beginning if needed.
38+
39+ // 4. paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2)
40+ // Takes everything except the final two characters to get the pounds
41+
42+ // 5. paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0")
43+ // Takes the final two characters to get the pence and adds "0" at the end if needed
44+
45+ // 6. console.log(`£${pounds}.${pence}`)
46+ // Displays the price in pounds and pence, such as £3.99
47+
You can’t perform that action at this time.
0 commit comments