0

hai can anyone hep me to correct the code on using loop and function in BMI

<!DOCTYPE.html> <html> <body> <h1>loop and function</h1> <script> function BMIcalc() { var cat=""; var weight = prompt("Masukkan jumlah berat (kg) :"); var height = prompt("Masukkan jumlah tinggi (cm) :"); function operation(x,y) { //return w; //return h; var errMsg =""; if (w <= 0) } errMsg = errMsg +"* Weight cannot be negative \n"; } if (h <=0) { errMsg = errMsg +"* Height cannot be negative \n"; } if(errMsg != "") { alert(errMsg); } else { w = x*1 h = y/100 var BMI = (w/ (Math.pow(h,2))); //document.write("BMI: " +BMI.toFixed(2)); if (BMI < 16) { //document.write("BMI: " +BMI +"<br> Category: Severe Thinness </br>"); cat="Category: Severe Thinness"; } else if ((BMI >= 16) && (BMI <= 17)) { //document.write("BMI: " +BMI +"<br> Category: Moderate Thinness </br>"); cat="Category: Moderate Thinness"; } else if ((BMI >= 17) && (BMI <= 18.5)) { //document.write("BMI: " +BMI +"<br> Category: Mild Thinness </br>"); cat="Category: Mild Thinness"; } else if ((BMI >= 18.5) && (BMI <= 25)) { //document.write("BMI: " +BMI +"<br> Category: Normal </br>"); cat="Category: Normal"; } else if ((BMI >= 25) && (BMI <= 30)) { //document.write("BMI: " +BMI +"<br> Category: Overweight </br>"); cat="Category: Overweight"; } else if ((BMI >= 30) && (BMI <= 35)) { //document.write("BMI: " +BMI +"<br> Category: Obese Class I </br>"); cat="Category: Obese Class I"; } else if ((BMI >= 35) && (BMI <= 40)) { //document.write("BMI: " +BMI +"<br> Category: Obese Class II </br>"); cat="Category: Obese Class II"; } else{ //document.write("BMI: " +BMI +"<br> Category: Obese Class III </br>"); cat="Category: Obese Class III"; } { answer = input("Would you like to enter another? key y/n: ") while answer == "y": start() answer = None if answer == "n": exit() } output (BMI,cat) function output(x,y)

20th Oct 2019, 8:32 AM
Tilageswary Chandran
Tilageswary Chandran - avatar
5 ответов
+ 4
Hi, would you mind linking to your code on the playground instead of including it in the description? It might maximize your chances to receive useful answers. https://www.sololearn.com/post/75089/?ref=app
20th Oct 2019, 8:56 AM
Tashi N
Tashi N - avatar
0
but still i couldn't run it
20th Oct 2019, 1:24 PM
Tilageswary Chandran
Tilageswary Chandran - avatar
0
yes i done it the result shows loop and function
20th Oct 2019, 1:45 PM
Tilageswary Chandran
Tilageswary Chandran - avatar