File tree Expand file tree Collapse file tree 4 files changed +51
-2
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 4 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -2,5 +2,4 @@ node_modules
22.DS_Store
33.vscode
44testing.js --- IGNORE ---
5- testing.js
65** /.DS_Store
Original file line number Diff line number Diff line change 1616
1717function calculateBMI ( weight , height ) {
1818 // return the BMI of someone based off their weight and height
19- }
19+ let squaredHeight = height * height ;
20+ let BMI = weight / squaredHeight ;
21+ BMI = BMI . toFixed ( 1 ) ;
22+ return Number ( BMI ) ;
23+ }
24+
25+ console . log ( calculateBMI ( 70 , 1.73 ) ) ;
26+ //console.log(calculateBMI(70, 1.73) + 5);
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 ( string )
19+ {
20+ let output = '' ;
21+ for ( let i = 0 ; i < string . length ; i ++ )
22+ {
23+ let char = string [ i ] ;
24+ if ( char === " " )
25+ {
26+ char = "_" ;
27+ }
28+ output += char ;
29+ }
30+ return output . toUpperCase ( ) ;
31+ }
32+
33+ console . log ( toUpperSnakeCase ( "Hello there, How are you doing guys?" ) ) ;
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+ function toPounds ( penceString )
9+ {
10+ const penceStringWithoutTrailingP = penceString . substring (
11+ 0 ,
12+ penceString . length - 1
13+ ) ;
14+
15+ const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
16+ const pounds = paddedPenceNumberString . substring (
17+ 0 ,
18+ paddedPenceNumberString . length - 2
19+ ) ;
20+
21+ const pence = paddedPenceNumberString
22+ . substring ( paddedPenceNumberString . length - 2 )
23+ . padEnd ( 2 , "0" ) ;
24+
25+ return ( `£${ pounds } .${ pence } ` ) ;
26+ }
27+
28+ console . log ( toPounds ( "5764p" ) ) ;
29+ console . log ( toPounds ( "813p" ) ) ;
30+ console . log ( toPounds ( "90897867564p" ) ) ;
31+ console . log ( toPounds ( "71p" ) ) ;
32+ console . log ( toPounds ( "312987p" ) ) ;
You can’t perform that action at this time.
0 commit comments