File tree Expand file tree Collapse file tree
Sprint-3/3-mandatory-implement Expand file tree Collapse file tree 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 ( pence ) {
9- //Declare penceString variable
10- let penceString = pence ;
11- // Store penceString value with pence on the end and make sure its at least 3 characters long add 0 at start if needed.
12- let penceStringWithoutTrailingP = penceString
13- . substring ( 0 , penceString . length - 1 )
9+ // Store pence value with pence on the end and make sure its at least 3 characters long add 0 at start if needed.
10+ const penceWithoutTrailingP = pence
11+ . substring ( 0 , pence . length - 1 )
1412 . padStart ( 3 , "0" ) ;
1513 // copy everything apart from the last two characters
16- let poundsResult = penceStringWithoutTrailingP . substring (
14+ const poundsResult = penceWithoutTrailingP . substring (
1715 0 ,
18- penceStringWithoutTrailingP . length - 2 ,
16+ penceWithoutTrailingP . length - 2 ,
1917 ) ;
2018 // start at the last two characters and take everything from there to end and make sure that value is two characters long add 0 if needed
21- let penceResult = penceStringWithoutTrailingP
22- . substring ( penceStringWithoutTrailingP . length - 2 )
19+ const penceResult = penceWithoutTrailingP
20+ . substring ( penceWithoutTrailingP . length - 2 )
2321 . padEnd ( 2 , "0" ) ;
2422 // return result of poundResult and penceResult in a template string
2523 return `£${ poundsResult } .${ penceResult } ` ;
You can’t perform that action at this time.
0 commit comments