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

152
Vistas
why is array split only splitting the first characters and leaving the last two

I have the following js code.

When I call the arrHelper function with the string "martin" I have noticed that my console.log is only showing the first three characters i.e ["m", "a", "r"] but not the full ["m", "a", "r","t","i","n"]. This happens even when I change the argument to a different name I am not getting the full converted array. This does not happen if I don't use the function Array.isArray().

let arrHelper = (str) => {
  let splittedStr = Array.isArray(str) ? str : str.split('')
  console.log(splittedStr)
  return (
    splittedStr.map((v, i, a) => {
      return (
        a.splice(-1)
      )
    })
  )
}

console.log(arrHelper("martin"));

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