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

458
Vistas
.Splice() Method Not Working Properly - What I am Missing Here?

I have this code, and all I'm tryin' to do is delete values from the original arr array which are not numbers to output a revised array with number values only.

For some reason, it manages to weed out through certain values but not the others (check the console output below. The debugger didn't shed much light on this behaviour - could someone please help?

const arr = [3, 9, NaN, false, 13, -10, false, 17, 14, 9, 5, true, "error", true, false, "error", false];

for (let i = 0; i < arr.length; i++) {
  if (typeof arr[i] !== "number" || isNaN(arr[i]))
    arr.splice(i, 1);

}

console.log(arr);

about 4 years ago · Juan Pablo Isaza
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