Skip to content

Commit 2c96140

Browse files
committed
Fix toPounds function
1 parent d90778b commit 2c96140

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

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

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

66
// You should call this function a number of times to check it works for different inputs
77
function toPounds(pence) {
8-
return pence / 100;
8+
const penceNumber = Number(pence.replace("p", ""));
9+
const pounds = penceNumber / 100;
10+
return `£${pounds.toFixed(2)}`;
911
}
1012

11-
console.log(toPounds(100));
12-
console.log(toPounds(250));
13-
console.log(toPounds(500));
13+
console.log(toPounds("399p"));
14+
console.log(toPounds("5p"));
15+
console.log(toPounds("2500p"));

0 commit comments

Comments
 (0)