File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1- // In Sprint-1, there is a program written in interpret/to-pounds.js
1+ // Define a function that converts kilograms to pounds
2+ function toPounds ( kg ) {
3+ const pounds = kg * 2.20462 ;
4+ return pounds . toFixed ( 2 ) ; // rounds to 2 decimal places
5+ }
26
3- // You will need to take this code and turn it into a reusable block of code.
4- // You will need to declare a function called toPounds with an appropriately named parameter.
5-
6- // You should call this function a number of times to check it works for different inputs
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
You can’t perform that action at this time.
0 commit comments