File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Sprint-1/3-mandatory-interpret Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1- const penceString = "399p" ;
1+ const penceString = "9p" ; //init variable
22
33const penceStringWithoutTrailingP = penceString . substring (
44 0 ,
55 penceString . length - 1
6- ) ;
6+ ) ; //remove p character at the end of the variable
7+ console . log ( penceStringWithoutTrailingP ) ;
8+
9+ const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ; //
10+ console . log ( paddedPenceNumberString ) ; //give format of 3 zeroes if the number is less than 3 digits.
711
8- const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
912const pounds = paddedPenceNumberString . substring (
1013 0 ,
1114 paddedPenceNumberString . length - 2
12- ) ;
15+ ) ; //get ponds value conversion changes for given pence
16+
17+ console . log ( pounds ) ;
1318
1419const pence = paddedPenceNumberString
1520 . substring ( paddedPenceNumberString . length - 2 )
16- . padEnd ( 2 , "0" ) ;
21+ . padEnd ( 2 , "0" ) ; //get the reminds after conversion to pounds
1722
1823console . log ( `£${ pounds } .${ pence } ` ) ;
1924
You can’t perform that action at this time.
0 commit comments