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

221
Vistas
Remove the last character of each string in array (JavaScript)

I have an array with strings in which I want to remove the last character. How can I make it possible to remove the last character for all strings that I have in the array?

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

0

use a .map() to get a new array and for each item do a .slice(0,-1) to remove the last char.

const array = ['abcd', '1234', 'cde', 'dot.']
const withoutLastChar = array.map(string => string.slice(0, -1));

console.log(withoutLastChar);

about 4 years ago · Juan Pablo Isaza Denunciar

0

you can used this way

const array = ['ab', 'aabb', 'ba', 'bbaa'];

const removingLastChar = array.map(string => string.substring(0, string.length - 1));

 console.log({ removingLastChar });

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