File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 3 files changed +37
-2
lines changed 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+ const weight = 103 ;
18+ const height = 1.87 ;
19+
1720function calculateBMI ( weight , height ) {
18- // return the BMI of someone based off their weight and height
19- }
21+ return calculatedBMI = ( weight / ( height * height ) ) . toFixed ( 1 ) ;
22+ }
23+
24+ console . log ( `the BMI of the person is ${ calculateBMI ( weight , height ) } ` ) ;
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 magicToUpperCase ( input )
19+ {
20+ return input . toUpperCase ( ) . replaceAll ( " " , "_" ) ;
21+
22+ }
23+
24+ console . log ( magicToUpperCase ( "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 ( penceCount ) {
10+
11+ const penceWithoutP = penceCount . substring (
12+ 0 ,
13+ penceCount . length - 1
14+ ) ;
15+
16+ const paddedPenceNumber = penceWithoutP . padStart ( 3 , "0" ) ;
17+ const pounds = paddedPenceNumber . substring (
18+ 0 ,
19+ paddedPenceNumber . length - 2
20+ ) ;
21+
22+ const pence = paddedPenceNumber
23+ . substring ( paddedPenceNumber . length - 2 ) ;
24+
25+ return `${ pounds } .${ pence } ` ;
26+ }
27+
28+ console . log ( `The amount in pounds is ${ toPounds ( "10000000" ) } ` ) ;
You can’t perform that action at this time.
0 commit comments