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,19 @@ 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+ // 2. const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1);
30+ // create a new variable and put the string without p
31+
32+ // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
33+ // padStart() adds characters to the beginning of a string to make it 3 characters long.
34+ // because we need to convert it to pound and pence
35+
36+ // 4. const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2);
37+ // We remove the last 2 characters and store the remaining part of the string as pounds.
38+
39+ // 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
40+ // Gets the last two characters as pence.”
41+
42+ // 6. console.log(`£${pounds}.${pence}`);
43+ //. Finally combine pound and pence
You can’t perform that action at this time.
0 commit comments