Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calculateBMI(name, age, weight, height) {
- const obj = {
- 'name': name,
- 'personalInfo': {
- 'age': age,
- 'weight': weight,
- 'height': height
- }
- };
- const notRounded = weight / (height / 100 * height / 100);
- obj.BMI = Math.round(notRounded);
- obj.status = (function (index) {
- if (index < 18.5) {
- return 'underweight';
- } else if (index < 25) {
- return 'normal';
- } else if (index < 30) {
- return 'overweight';
- } else {
- obj.recommendation = 'admission required';
- return 'obese';
- }
- })(notRounded);
- return obj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement