bobo_bobkata

Untitled

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