File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 66// You should call this function a number of times to check it works for different inputs
77
88function 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"
You can’t perform that action at this time.
0 commit comments