Advertisement
Guest User

Untitled

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