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

412
Vistas
Why does Number.isInteger() return false even when I prompt in integer values?
do {
    var y = prompt("Enter a positive integer from 1 to 26");
    var int = Number.isInteger(y);
    var x = parseInt(y);
    window.alert(int);
} while (x > 26 || x < 1 || int == false)

this is the code I wrote but it still keeps alerting int as false whenever I enter an integer on my browser.

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

0

Number.isInteger() is used to tell if a value that's already a number is an integer.

I.e.

Number.isInteger(5) == true
Number.isInteger(5.1) == false

Passing a string into Number.isInteger() will always return false.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Because prompt() always returns a string. It is up to you to make it integer:

let y = prompt("Enter a positive integer from 1 to 26");
y = parseInt(y);
if (y === NaN) {
    alert('Please enter a number');
} else {
    while(x > 26 || x < 1 || int == false)
}
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