kingvlad

BMI Calculator challenge

Aug 26th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. //Create your function below this line.
  2.  
  3.  
  4.  
  5.  
  6. /* If my weight is 65Kg and my height is 1.8m, I should be able to call your function like this:
  7.  
  8. var bmi = bmiCalculator(65, 1.8);
  9.  
  10. bmi should equal around 20 in this case.
  11.  
  12. */
  13.  
  14. function bmiCalculator(yourWeight, yourHeight){
  15. console.log("Your BMI is " + calculator (yourWeight, yourHeight));
  16. }
  17.  
  18.  
  19. // function round(yourWeight, yourHeight) {
  20.  
  21. // var roundOff = Math.round(yourWeight, yourHeight);
  22. // return roundOff;
  23. // }
  24.  
  25. function calculator(yourWeight, yourHeight) {
  26. // var calc = yourWeight / (Math.sqrt(yourHeight));
  27. // return calc;
  28. var calc = (yourWeight) / (Math.pow(yourHeight, 2));
  29. return Math.floor(calc);
  30. }
  31.  
  32.  
  33. var bmi = bmiCalculator(65, 1.8);
Advertisement
Add Comment
Please, Sign In to add comment