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

133
Views
Reducir las devoluciones de métodos

¿Por qué la segunda asignación necesita devolución y la primera devuelve el total variable automáticamente?

 const total = inventors.reduce(((total, inventor) => total += inventor.passed - inventor.born), 0);
 const transportation = data.reduce(((prevVal, currentVal) => { if (!prevVal[currentVal]) { prevVal[currentVal] = 0; } prevVal[currentVal]++; return prevVal; }), {})

Si se omite return prevVal, obtengo TypeError no capturado: no se pueden leer las propiedades de undefined

¿Cuál es la diferencia en cómo reduce() actúa con los valores? ¿Se efectúa por operación ternaria? Si es así, ¿por qué esto devuelve 0?

 const transportation = data.reduce(((prevVal, currentVal) => (!prevVal[currentVal]) ? prevVal[currentVal] = 0 : prevVal[currentVal]++), {})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Al usar llaves con una función de flecha, el retorno no está implícito, por lo que debe usar return

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!