gadjov

Personal BMI

Nov 4th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function PersonalBMI(inputArg) {
  2.     let arg = {
  3.         name: inputArg[0],
  4.         personalInfo: {
  5.             age: inputArg[1],
  6.             wight: inputArg[2],
  7.             height: inputArg[3]
  8.         },
  9.         BMI: '',
  10.         status: ''
  11.     };
  12.     arg.BMI = calculate();
  13.     function calculate() {
  14.         let height = arg.personalInfo.height / 100;
  15.         let wight = arg.personalInfo.wight;
  16.         let result = Math.ceil(wight / (height * height));
  17.         return result;
  18.     }
  19.     arg.status = statusChecker(arg.BMI);
  20.     console.log(arg);
  21.     function statusChecker(bmi) {
  22.         if (bmi < 18.5) {
  23.             return 'underweight';
  24.         }
  25.         if (bmi < 25) {
  26.             return 'normal';
  27.         }
  28.         if (bmi < 30) {
  29.             return 'overweight';
  30.         }
  31.         if (bmi >= 30) {
  32.             return 'obese';
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment