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

101
Vistas
¿Cómo puede el código JS eliminar una cadena en blanco entre otras cadenas en el texto?

Para JS, se establece una matriz de texto en la variable arr :

 let arr = ["When I consider every thing that grows", "", "Holds in perfection but a little moment,", "", "That this huge stage presenteth nought but shows", "", "Whereon the stars in secret influence comment;"];

Cómo quitarle las líneas vacías y que quede como una matriz, pero sin las cadenas vacías:

resultado

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Puedes usar un filtro booleano para esto:

 arr.filter(Boolean)

Código completo:

 let arr = [ "When I consider every thing that grows", "", "Holds in perfection but a little moment,", "", "That this huge stage presenteth nought but shows", "", "Whereon the stars in secret influence comment;" ]; console.log(arr.filter(Boolean));

me da:

 [ "When I consider every thing that grows", "Holds in perfection but a little moment,", "That this huge stage presenteth nought but shows", "Whereon the stars in secret influence comment;" ]
about 4 years ago · Santiago Trujillo 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