Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
¿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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!