File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 3 files changed +34
-2
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- // return the BMI of someone based off their weight and height
19- }
18+ let BMI = weight / ( height * height ) ;
19+ return BMI . toFixed ( 1 ) ;
20+ }
21+ console . log ( calculateBMI ( 70 , 1.73 ) ) ;
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 ConvertToUpperSnakeCase ( s1 )
19+ {
20+ let result = "" ;
21+ for ( let i = 0 ; i < s1 . length ; i ++ )
22+ {
23+
24+ if ( s1 [ i ] === " " )
25+ {
26+ result += s1 [ i ] = "_" ;
27+ }
28+ else
29+ result += s1 [ i ] ;
30+ }
31+ let UPPER_SNAKE_CASE = result . toUpperCase ( ) ;
32+ return UPPER_SNAKE_CASE ;
33+ }
34+ console . log ( ConvertToUpperSnakeCase ( "Ahmad Hmedan" ) ) ;
35+
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 toPound ( penceString )
10+ {
11+ const penceWithoutP = penceString . substring ( 0 , penceString . length - 1 ) ;
12+ const paddedPence = penceWithoutP . padStart ( 3 , "0" ) ;
13+ const pound = paddedPence . substring ( 0 , paddedPence . length - 2 ) ;
14+ const Pence = paddedPence . substring ( paddedPence . length - 2 ) ;
15+ return `£${ pound } .${ Pence } `
16+ }
17+ console . log ( toPound ( "100p" ) ) ;
You can’t perform that action at this time.
0 commit comments