Skip to content

Commit 0cf04ad

Browse files
committed
implement toPounds
1 parent 46db88c commit 0cf04ad

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@
44
// You will need to declare a function called toPounds with an appropriately named parameter.
55

66
// You should call this function a number of times to check it works for different inputs
7+
function toPounds(penceString) {
8+
const pence = Number(penceString.replace("p", ""));
9+
return `£${(pence / 100).toFixed(2)}`;
10+
}
11+
12+
console.log(toPounds("399p"));
13+
console.log(toPounds("5p"));
14+
console.log(toPounds("50p"));
15+
console.log(toPounds("1250p"));
16+
console.log(toPounds("0p"));

0 commit comments

Comments
 (0)