File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ function toPounds (penceString) {
3232 return `£${ pounds } .${ pence } ` ;
3333}
3434console . log ( toPounds ( "399p" ) ) ;
35+ console . log ( toPounds ( "5p" ) )
36+ console . log ( toPounds ( "007p" ) ) ; // leading zeroes handled -> £0.07
37+ // Edge cases and inputs this function does not handle well (demonstration)
38+ // 1) Missing trailing 'p' – the current implementation will drop the last character,
39+ // so "399" is treated like "39" and becomes £0.39 (not what we want)
40+ console . log ( toPounds ( "399" ) ) ;
41+
42+ // 2) Different trailing character – the function does not validate the trailing 'p',
43+ // it simply removes the last character. "399P" still returns £3.99
44+ console . log ( toPounds ( "399P" ) ) ;
3545
3646// This program takes a string representing a price in pence
3747// The program then builds up a string representing the price in pounds
You can’t perform that action at this time.
0 commit comments