@@ -2,13 +2,13 @@ const penceString = "399p";
22
33const penceStringWithoutTrailingP = penceString . substring (
44 0 ,
5- penceString . length - 1
5+ penceString . length - 1 ,
66) ;
77
88const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
99const pounds = paddedPenceNumberString . substring (
1010 0 ,
11- paddedPenceNumberString . length - 2
11+ paddedPenceNumberString . length - 2 ,
1212) ;
1313
1414const pence = paddedPenceNumberString
@@ -27,17 +27,17 @@ console.log(`£${pounds}.${pence}`);
2727// 1. const penceString = "399p": initialises a string variable with the value "399p"
2828
2929// 2. const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1);
30- // create a new variable and put the string without p
30+ // create a new variable and put the string without p
3131
3232// 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
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
3535
3636// 4. const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2);
3737// We remove the last 2 characters and store the remaining part of the string as pounds.
3838
3939// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
40- // Gets the last two characters as pence.”
40+ // Gets the last two characters as pence.”
4141
42- // 6. console.log(`£${pounds}.${pence}`);
43- //. Finally combine pound and pence
42+ // 6. console.log(`£${pounds}.${pence}`);
43+ //. Finally combine pound and pence
0 commit comments