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

57
Views
¿Cómo destruir una matriz de números en un objeto y combinarlos en uno en javascript?

tengo este objeto:

 const memorized = [ { verses: [1, 2, 3, 4, 5], when: '2022 Jan 14' }, { verses: [6, 7, 8, 9] when: '2022 Jan 15' }, { verses: [10, 11, 12, 13, 14, 15] when: '2022 Jan 16' }, ... ]

y cómo puedo obtener el total de versos como este:

 const total_verses = [1, 2, 3, 4, 5, ..., 15]

Mi posible solución sería:

 let total_verses = [] memorized.map(ar => total_verses.push(...ar.verses))

Pero me gustaría hacerlo simplemente filtrando o mapeando.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No es necesario presionar cuando mapea, eso es desperdiciar una matriz

O presione un forEach o simplemente mapee la matriz

 const memorized = [ { verses: [1, 2, 3, 4, 5], when: '2022 Jan 14' }, { verses: [6, 7, 8, 9], when: '2022 Jan 15' }, { verses: [10, 11, 12, 13, 14, 15], when: '2022 Jan 16' } ]; const total_verses = memorized.flatMap(({ verses }) => verses) console.log(total_verses);

about 4 years ago · Juan Pablo Isaza 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!