Skip to content

Commit a1ae7a3

Browse files
committed
fixed the implementation of pounds to pence
1 parent bd6a95d commit a1ae7a3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
// You should call this function a number of times to check it works for different inputs
77

8-
function toPounds(kilograms) {
9-
return +(kilograms * 2.20462).toFixed(1);
8+
function toPounds(penceString) {
9+
const pence = Number(penceString.slice(0, -1));
10+
return ${(pence / 100).toFixed(2)}`;
1011
}
11-
console.log(toPounds(1)); // should return 2.2
12-
console.log(toPounds(5)); // should return 11
13-
console.log(toPounds(10)); // should return 22
12+
console.log(toPounds("100p")); // should return £1.00
13+
console.log(toPounds("399p")); // should return £3.99
14+
console.log(toPounds("10p")); // should return £0.10

0 commit comments

Comments
 (0)