elena1234

How to work with complicate objects ( JavaScript)

Nov 30th, 2021
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(name, age, weight, height) {
  2. let object = {
  3.     name: name,
  4.     personalInfo: {
  5.         age: age,
  6.         weight: weight,
  7.         height: height
  8.     },
  9.     BMI: Math.round(weight /(height * height / 10000))
  10. };
  11.  
  12. object.status = object.BMI < 18.5 ? "underweight" : object.BMI < 25 ? "normal" : object.BMI < 30 ? "overweight" : "obese";
  13.  
  14. if(object.status == "obese") {
  15.     object.recommendation = "admission required";
  16. }
  17.  
  18. return object;
  19. }
  20.  
  21. console.log(solve('Peter', 29, 75, 182));
RAW Paste Data