Advertisement
YavorGrancharov

Personal BMI

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