@@ -26,19 +26,19 @@ console.log(`£${pounds}.${pence}`);
2626// To begin, we can start with
2727// 1. const penceString = "399p": initialises a string variable with the value "399p"
2828
29- 1. const penceString = "399p" // Stores "399p" in a variable called penceString so the program can work with the price.
30- 2. const penceStringWithoutTrailingP = penceString . substring (
31- 0 ,
32- penceString . length - 1
33- ) ; // Removes the "p" from the end of "399p", leaving "399"
34- 3. const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
29+ // 1. const penceString = "399p" // Stores "399p" in a variable called penceString so the program can work with the price.
30+ // 2. const penceStringWithoutTrailingP = penceString.substring(
31+ // 0,
32+ // penceString.length - 1);
33+ // Removes the "p" from the end of "399p", leaving "399"
34+ // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
3535//Adds a "0" at the start if there are less than 3 digits.
36- 4. const pounds = paddedPenceNumberString . substring (
37- 0 ,
38- paddedPenceNumberString . length - 2 ) ; //gets the digits before the last two to find the pounds.
36+ // 4. const pounds = paddedPenceNumberString.substring(
37+ // 0,
38+ // paddedPenceNumberString.length - 2); //gets the digits before the last two to find the pounds.
3939
40- 5. const pence = paddedPenceNumberString
41- . substring ( paddedPenceNumberString . length - 2 )
42- . padEnd ( 2 , "0" ) ; //gets the last two digits to find the pence.
40+ // 5. const pence = paddedPenceNumberString
41+ // .substring(paddedPenceNumberString.length - 2)
42+ // .padEnd(2, "0"); //gets the last two digits to find the pence.
4343
44- 6. console . log ( `£${ pounds } .${ pence } ` ) ; //Combines the pounds and pence and print the final price as £3.99
44+ // 6. console.log(`£${pounds}.${pence}`); //Combines the pounds and pence and print the final price as £3.99
0 commit comments