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

116
Views
¿Por qué se necesita el 0 después de "(arr[i] || 0)"?

Para el siguiente código, me pregunto por qué se necesita el último "0" después de "(arr[i] || 0)".

Reconozco que sin este "0" el código no se ejecuta según lo previsto, pero en realidad no obtengo lo que el último "0" después de "," hace que funcione.

¿Alguien podría explicarlo?

 function addTogether (...arrays) { let result = []; let arrayLength = Math.max(...arrays.map(array => array.length)); for (let i = 0; i < arrayLength; i++) { result.push(arrays.reduce((sum, arr) => sum + (arr[i] || 0), 0)); } return result } test(addTogether([1, 2, 3], [4, 5], [6]), [11, 7, 3]);

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