Skip to content

Commit 17480c0

Browse files
committed
updated the code with(lbs) at the end
This function converts the weight in kg to pounds
1 parent a4cfc97 commit 17480c0

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
// You should call this function a number of times to check it works for different inputs
77

88
function toPounds(kg) {
9-
const pounds = kg * 2.20462;
10-
11-
return pounds;
9+
const pounds = kg * 2.20462;
10+
return `${pounds.toFixed(2)} lbs`; // returns a string
1211
}
13-
console.log(toPounds(1));
14-
console.log(toPounds(5));
15-
console.log(toPounds(10));
16-
// if I want to round the result to 2 decimal places I can use toFixed(2)
17-
console.log(toPounds(1).toFixed(2));
18-
console.log(toPounds(5).toFixed(2));
19-
console.log(toPounds(10).toFixed(2));
12+
13+
// Test cases
14+
console.log(toPounds(1)); //the output "2.20 lbs"
15+
console.log(toPounds(5)); //the output is "11.02 lbs"
16+
console.log(toPounds(10)); //the output is "22.05 lbs"

0 commit comments

Comments
 (0)