Hello there,
I've made the following code: (helper.js)
export const getBMICategory = (bmi) => {
if (bmi < 18.6 ) {
return 'Underweight';
}
if (bmi < 25 ) {
return 'Normal weight';
}
if (bmi < 30 ) {
return 'Overweight';
}
if (bmi > 29.99 ) {
return 'Obesity';
}
}
I haven't touch this: (solution.js)
/**
* - **Underweight** = 18.5 or less
* - **Normal weight** = greater than 18.5 and less than 25
* - **Overweight** = starting at 25 and less than 30
* - **Obesity** = 30 or greater
**/
import { getBMICategory } from './helper.js';
console.log(getBMICategory(10)); // Underweight
console.log(getBMICategory(20)); // Normal weight
console.log(getBMICategory(40)); // Obesity
When I press the button Run your code I get the right results, and when pressing the button Submit task I will probably get a Status DONE.
I wonder if what I made is good practice code when using all these if statements or is there a better way to do this?