Advertisement
simonradev

ASd

Feb 26th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calculateBMI(name, age, weight, height) {
  2.     const obj = {
  3.         'name': name,
  4.         'personalInfo': {
  5.             'age': age,
  6.             'weight': weight,
  7.             'height': height
  8.         }
  9.     };
  10.    
  11.     const notRounded = weight / (height / 100 * height / 100);
  12.     obj.BMI = Math.round(notRounded);
  13.  
  14.     obj.status = (function (index) {
  15.         if (index < 18.5) {
  16.             return 'underweight';
  17.         } else if (index < 25) {
  18.             return 'normal';
  19.         } else if (index < 30) {
  20.             return 'overweight';
  21.         } else {
  22.             obj.recommendation = 'admission required';
  23.             return 'obese';
  24.         }
  25.     })(notRounded);
  26.  
  27.     return obj;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement