Skip to content

Commit 33625fc

Browse files
committed
pound.pence code
1 parent 74fe2da commit 33625fc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@
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+
8+
function toPounds(penceAmount) {
9+
const padded = penceAmount.padStart(3, "0");
10+
const pounds = padded.substring(0, padded.length - 2);
11+
const pence = padded.substring(padded.length - 2);
12+
return ${pounds}.${pence}p`;
13+
}
14+
15+
console.log(toPounds("399"));

0 commit comments

Comments
 (0)