Skip to content

Commit ed8ad94

Browse files
committed
Address comment on 3-to-pounds.js
1 parent d687a21 commit ed8ad94

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sprint-2/3-mandatory-implement/3-to-pounds.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ function toPounds (penceString) {
3232
return ${pounds}.${pence}`;
3333
}
3434
console.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

0 commit comments

Comments
 (0)