File tree Expand file tree Collapse file tree 2 files changed +21
-25
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 2 files changed +21
-25
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- let bmi = weight / ( height * height ) ;
20- bmi = Number ( bmi . toFixed ( 1 ) ) ;
21- return bmi ;
18+ // return the BMI of someone based off their weight and height
19+ let bmi = weight / ( height * height ) ;
20+ bmi = Number ( bmi . toFixed ( 1 ) ) ;
21+ return bmi ;
2222}
2323
2424let actualOutput = calculateBMI ( 70 , 1.73 ) ;
25- console . log ( actualOutput ) ; // 23.4
25+ console . log ( actualOutput ) ; // 23.4
Original file line number Diff line number Diff line change 55
66// You should call this function a number of times to check it works for different inputs
77
8-
9-
108function toPounds ( penceString ) {
11- const penceStringWithoutTrailingP = penceString . substring (
12- 0 ,
13- penceString . length - 1
14- ) ;
9+ const penceStringWithoutTrailingP = penceString . substring (
10+ 0 ,
11+ penceString . length - 1
12+ ) ;
1513
16- const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
17- const pounds = paddedPenceNumberString . substring (
18- 0 ,
19- paddedPenceNumberString . length - 2
20- ) ;
14+ const paddedPenceNumberString = penceStringWithoutTrailingP . padStart ( 3 , "0" ) ;
15+ const pounds = paddedPenceNumberString . substring (
16+ 0 ,
17+ paddedPenceNumberString . length - 2
18+ ) ;
2119
22- const pence = paddedPenceNumberString
23- . substring ( paddedPenceNumberString . length - 2 )
24- . padEnd ( 2 , "0" ) ;
20+ const pence = paddedPenceNumberString
21+ . substring ( paddedPenceNumberString . length - 2 )
22+ . padEnd ( 2 , "0" ) ;
2523
2624 return `£${ pounds } .${ pence } ` ;
2725
28- // console.log(`£${pounds}.${pence}`);
26+ // console.log(`£${pounds}.${pence}`);
2927}
3028
31-
32-
33- console . log ( toPounds ( "399p" ) ) ;
34- console . log ( toPounds ( "5p" ) ) ;
35- console . log ( toPounds ( "50p" ) ) ;
29+ console . log ( toPounds ( "399p" ) ) ;
30+ console . log ( toPounds ( "5p" ) ) ;
31+ console . log ( toPounds ( "50p" ) ) ;
3632console . log ( toPounds ( "1234p" ) ) ;
You can’t perform that action at this time.
0 commit comments