Skip to content

Commit 0de1e19

Browse files
committed
turn interpret/to-pounds.js into a reuseable block of code
1 parent c52e087 commit 0de1e19

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
@@ -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 formaPenceToPounds(penceString){
8+
const penceStringWithoutTrailingP = penceString.substring(0, penceString.length -1);
9+
const pounds = paddedPenceNumberString.slice(0, -2);
10+
const pence = paddedPenceNumberString.slice(-2);
11+
return ${pounds}.${pence}`;
12+
}
13+
14+
console.log(formatPenceToPounds("9p"));
15+
console.log(formatPenceToPounds("39p"));
16+
console.log(formatPenceToPounds("399"));

0 commit comments

Comments
 (0)