Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Please explain the reason for this code not working

The code given below should give different output on the basis of the input values but it is not working.

function myFunction() {
  let x = document.getElementById("demo").value;
  let y;
  if (x == "") {
    y = "The field is Empty";
  } else if (isNaN(x)) {
    y = "Input is not a number";
  } else if (x < 5) {
    y = "The number is too low";
  } else(x > 10) {
    y = "The number is too big";
  }
  document.getElementById("p01").innerHTML = y;
}
<input id="demo" type="text">
<button type="button" onclick="myFunction()">Test Input</button>
<p id="p01"></p>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are putting a condition in the else statement: else (x > 10) which can't be done. Change it to else if (x > 10) and you should be good to go.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda