File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1515// It should return their Body Mass Index to 1 decimal place
1616
1717function calculateBMI ( weight , height ) {
18- let result = weight / ( height * height ) ;
18+ let result = Number ( weight / ( height * height ) ) ;
1919 return result . toFixed ( 1 ) ;
2020
21- // return the BMI of someone based off their weight and height
21+
2222}
2323
24- console . log ( calculateBMI ( 70 , 168 ) )
24+ console . log ( calculateBMI ( 70 , 1.7 ) )
25+ console . log ( calculateBMI ( 72 , 1.7 ) )
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+ function toUpperSnakeFormat ( string ) {
18+ return string . toUpperCase ( ) . replaceAll ( " " , "_" )
19+
20+ }
21+ console . log ( toUpperSnakeFormat ( "hello there" ) )
22+ console . log ( toUpperSnakeFormat ( "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+ function toPounds ( penceString ) {
8+ const penceStringWithoutTrailingP = penceString . substring (
9+ 0 ,
10+ penceString . length - 1
11+ ) ;
12+ const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
13+ const pounds = paddedPenceNumberString . substring (
14+ 0 ,
15+ paddedPenceNumberString . length - 2
16+ ) ;
17+
18+ const pence = paddedPenceNumberString
19+ . substring ( paddedPenceNumberString . length - 2 )
20+ . padEnd ( 2 , "0" ) ;
21+ return `£${ pounds } .${ pence } `
22+ }
23+
24+
25+ console . log ( toPounds ( '987p' ) ) ;
26+ console . log ( toPounds ( '909p' ) ) ;
27+ console . log ( toPounds ( '345p' ) ) ;
You can’t perform that action at this time.
0 commit comments