File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Sprint-1/3-mandatory-interpret Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -5,23 +5,23 @@ const penceStringWithoutTrailingP = penceString.substring(
55 0 ,
66 penceString . length - 1
77) ;
8- // declare a new var and assign penceString value without last character (p)/
8+ // Creates a new string that removes the last character (p) from penceString.
99
1010const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
11- //declare a new variable and Make sure it is at least 3 digits long eg: 1 become 001 .
11+ //Ensure the string has at least three digits by adding "0" to the start if needed .
1212
1313const pounds = paddedPenceNumberString . substring (
1414 0 ,
1515 paddedPenceNumberString . length - 2
1616) ;
17- //declare a new variable and assign the paddedPenceNumberString value without last two digit .
17+ //Extracts the pounds part by taking all characters except the last two digits .
1818
1919const pence = paddedPenceNumberString
2020 . substring ( paddedPenceNumberString . length - 2 )
2121 . padEnd ( 2 , "0" ) ;
22- // pence= take the pound length and remove it and keep all rest digit and if the shorter than 2 digit add 0 until paddedPenceNumberString
23- // .substring(paddedPenceNumberString.length - 2) becomes 2 digits
22+ //extract the last two digits to get the pence part.
2423console . log ( `£${ pounds } .${ pence } ` ) ;
24+ // Combines the pound and pence values into a formatted string.
2525
2626// This program takes a string representing a price in pence
2727// The program then builds up a string representing the price in pounds
You can’t perform that action at this time.
0 commit comments