Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
La función bmi devuelve Nan en la entrada rápida pero está bien en el valor asignado

Por favor, ayude a novato aquí: ¿Qué tiene de malo esto? ¿Por qué devuelve Nan si lo ingreso en el aviso, pero si coloqué el valor en bmiCalculator (60,2) devuelve 15?

 function bmiCalculator (weight, height) { prompt("Enter your weight in kg: " , weight); prompt("Enter your height m square: " , height); bmi=0; weight=0; height=0; bmi = weight/(height * height); if (bmi >= 0 && bmi < 18.5){ value="Underweight"; }else if (bmi >= 18.5 && bmi <= 24.9){ value="NORMAL"; }else if (bmi >= 24.9 && bmi <= 29.9){ value="OVERWEIGHT"; } else if (bmi >= 29.9 && bmi <= 34.9){ value="OBESE"; } else if (bmi <= 35) { value="EXTREMELY OBESE"; } interpretation = alert("Your BMI is " + bmi + " Therefore you are " + value ); return interpretation; } bmiCalculator();
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Tiene algunas variables que no se están configurando correctamente.

Primero, elimine los parámetros de su función, ya que está configurando la altura y el peso a través de un aviso.

 function bmiCalculator() { let weight = prompt("Enter your weight in kg: "); let height = prompt("Enter your height m square: ");

Luego, debe declarar el value :

 let value = '';

Aquí está el código actualizado a continuación:

 function bmiCalculator() { let weight = prompt("Enter your weight in kg: "); let height = prompt("Enter your height m square: "); let bmi = 0; let value; bmi = weight / (height * height); if (bmi >= 0 && bmi < 18.5) { value = "Underweight"; } else if (bmi >= 18.5 && bmi <= 24.9) { value = "NORMAL"; } else if (bmi >= 24.9 && bmi <= 29.9) { value = "OVERWEIGHT"; } else if (bmi >= 29.9 && bmi <= 34.9) { value = "OBESE"; } else if (bmi <= 35) { value = "EXTREMELY OBESE"; } interpretation = alert("Your BMI is " + bmi + " Therefore you are " + value); return interpretation; } bmiCalculator();

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda