Skip to content

Commit 19f296f

Browse files
committed
convert kg to pounds and round to 2 decimal places
1 parent bce599b commit 19f296f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
// Define a function that converts kilograms to pounds
22
function toPounds(kg) {
33
const pounds = kg * 2.20462;
4-
return pounds.toFixed(2); // rounds to 2 decimal places
4+
return Number(pounds.toFixed(2)); // return as number, not string
55
}
66

7-
// Call the function with different inputs to test it
8-
console.log(toPounds(1)); // 2.20
9-
console.log(toPounds(5)); // 11.02
10-
console.log(toPounds(70)); // 154.32
11-
console.log(toPounds(0)); // 0.00
7+
module.exports = toPounds;

0 commit comments

Comments
 (0)