Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. function checkBMI(name, age, weight, height) {
  2. let bmi = '';
  3. let object = {
  4. name: name,
  5. personalInfo: {age: Number(age), weight: Number(weight), height: Number(height)},
  6. BMI: (() => {
  7. return bmi = Math.round(weight / (Math.pow((height/100),2)));
  8. })(),
  9. status: (() => {
  10. if (bmi < 18.5) {
  11. return 'underweight'
  12. } else if (bmi < 25) {
  13. return 'normal'
  14. } else if (bmi < 30) {
  15. return 'overweight'
  16. } else {
  17. return 'obese'
  18. }
  19. })()
  20. };
  21. if (object.status != 'normal') {
  22. object['recommendation'] = 'admission required';
  23. }
  24. return object;
  25. }
  26. console.log(checkBMI('Peter', '29', '75', '182'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement