+ 1

Does anyone know how to calculate Body Mass Index (BMI)? Using "function" for 3 people.

Using "function", calculate 3 different BMI. => (84.5kg, 140kg, 83.9kg) => (1.8m, 1.93m, 1.65m) *with STATUS of according With BMI.

23rd Nov 2016, 10:13 PM
Sidnei Ferreira da Silva
Sidnei Ferreira da Silva - avatar
8 Respostas
+ 1
function(w1,h1,w2,h2,w3,h3) { var bmi1 = w1/(h1²); var bmi2 = w2/(h2²); var bmi3 = w3/(h3²); if(bmi1<16) var bmi1 = "Severe Thinness"; else if (bmi1==16 || bmi1==17) bmi1 = "Moderate Thinness"; else if (bmi1>17 && bmi1<=18.5) bmi1 = "Mild Thinness"; else if (bmi1>18.5 && bmi1<=25) bmi1 = "Normal"; else if (bmi1>25 && bmi1<=30) bmi1 = "Overweight"; else if (bmi1>30 && bmi1<=35) bmi1 = "Obese Class 1"; else if (bmi1>35 && bmi1<=40) bmi1 = "Obese Class 2"; else if (bmi1>40) bmi1 = "Obese Class 3"; //...do the same for bmi2 and bmi3 return "BMIs: first: " + bmi1 + " second: " + bmi2 + " third: " + bmi3; } if you use two functions, it'd be better cause you would nt need to rewrite those if's for each variable.
24th Nov 2016, 11:05 AM
Lucas Heim
Lucas Heim - avatar
+ 2
Hi Lucas, its code is good example. thank you for help!
30th Nov 2016, 10:53 PM
Sidnei Ferreira da Silva
Sidnei Ferreira da Silva - avatar
+ 1
in which language?
23rd Nov 2016, 10:47 PM
Lucas Heim
Lucas Heim - avatar
+ 1
In JavaScript
23rd Nov 2016, 11:44 PM
Sidnei Ferreira da Silva
Sidnei Ferreira da Silva - avatar
+ 1
not completely sure you can just assign double values and then string right after, didnt test it. In case you can't, just create another variable to store the text part
24th Nov 2016, 11:06 AM
Lucas Heim
Lucas Heim - avatar
+ 1
The code of Lucas, i will make using array to storage the parameters and run a for, no needing make more code... kk, sorry, i no speak inglish...
5th Jan 2019, 6:03 AM
RC0D3 M4X
RC0D3 M4X - avatar
+ 1
LoooL vc fala português kkk
5th Jan 2019, 6:04 AM
RC0D3 M4X
RC0D3 M4X - avatar
+ 1
Sim falo português.🙋
5th Jan 2019, 7:48 PM
Sidnei Ferreira da Silva
Sidnei Ferreira da Silva - avatar