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

96
Vistas
How to ignore escape characters in string.length javascript?

I have a NodeJS script that finds the longest string in a list, then appends spaces to make all other strings the same length. I have a problem, because I am using Chalk to color certain strings. The escape codes chalk produces are long, and when I get the length of 2 strings, let's say one is let 1 = chalk.greenBright("test") which its length should be 4, but it returns 14, and we have the other variable let 2 = "lorem ipsum" which its length should be 11. When I call .length, 1 is bigger than the other therefore causing this issue: (using E as space)

lorem ipsumEEE
test

Instead of the intended result:

lorem ipsum
testEEEEEEE
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