File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 66// You should call this function a number of times to check it works for different inputs
77
88function toPounds ( penceString ) {
9+ const penceStringWithoutTrailingP = penceString . substring (
10+ 0 ,
11+ penceString . length - 1
12+ ) ;
913
10- const penceStringWithoutTrailingP = penceString . substring ( 0 , penceString . length - 1 ) ;
14+ const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
15+ const pounds = paddedPenceNumberString . substring (
16+ 0 ,
17+ paddedPenceNumberString . length - 2
18+ ) ;
1119
12- const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
13- const pounds = paddedPenceNumberString . substring ( 0 , paddedPenceNumberString . length - 2 ) ;
20+ const pence = paddedPenceNumberString
21+ . substring ( paddedPenceNumberString . length - 2 )
22+ . padEnd ( 2 , "0" ) ;
1423
15- const pence = paddedPenceNumberString . substring ( paddedPenceNumberString . length - 2 ) . padEnd ( 2 , "0" ) ;
16-
17- return console . log ( `£${ pounds } .${ pence } ` ) ;
24+ return console . log ( `£${ pounds } .${ pence } ` ) ;
1825}
19- toPounds ( ' 399p' ) // £3.99
20- toPounds ( ' 1095p' ) // £10.95
26+ toPounds ( " 399p" ) ; // £3.99
27+ toPounds ( " 1095p" ) ; // £10.95
You can’t perform that action at this time.
0 commit comments