File tree Expand file tree Collapse file tree
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414// Then when we call this function with the weight and height
1515// It should return their Body Mass Index to 1 decimal place
1616
17- function calculateBMI ( weight , height ) {
18- // return the BMI of someone based off their weight and height
19- }
17+
18+ function calculateBMI ( weightkg , heightm ) {
19+ const BMI = ( weightkg / ( heightm * heightm ) ) ;
20+ return BMI . toFixed ( 1 ) ;
21+ }
22+ let result = calculateBMI ( 70 , 1.73 ) ;
23+ console . log ( result ) ;
Original file line number Diff line number Diff line change 1414// You will need to come up with an appropriate name for the function
1515// Use the MDN string documentation to help you find a solution
1616// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
17+
18+ function toUpperSnakeCase ( str ) {
19+ let newstr = str . replaceAll ( " " , "_" ) . toUpperCase ( ) ;
20+ return newstr ;
21+ }
22+ console . log ( toUpperSnakeCase ( "lord of the rings" ) ) ;
Original file line number Diff line number Diff line change 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+
8+
9+ function toPounds ( pence ) {
10+ const remainingPence = ( pence % 100 ) ;
11+ const Pounds = ( pence - remainingPence ) / 100 ;
12+ return `£${ Pounds } .${ remainingPence } ` ;
13+ }
14+
15+ console . log ( toPounds ( 155 ) ) ;
16+ console . log ( toPounds ( 99 ) ) ;
17+ console . log ( toPounds ( 10000 ) ) ;
You can’t perform that action at this time.
0 commit comments