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

123
Views
reducir en javascript usando retornos rizados indefinidos

Simplemente siguiendo el tutorial de mdn sobre reducir en javascript, ¿alguien puede explicarme por qué a continuación no puedo usar las llaves alrededor de la devolución de llamada?

 const array1 = [1, 2, 3, 4]; // 0 + 1 + 2 + 3 + 4 const initialValue = 0; // expected output: 10 const sumWithInitialTest = array1.reduce( (pv, cv) => { pv + cv } ) console.log(sumWithInitialTest)

Obviamente, sin llave, funciona bien

 const array1 = [1, 2, 3, 4]; // 0 + 1 + 2 + 3 + 4 const initialValue = 0; // expected output: 10 const sumWithInitialTest = array1.reduce( (pv, cv) => pv + cv ) console.log(sumWithInitialTest)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Agregue retorno si desea usar corchetes

 const array1 = [1, 2, 3, 4]; // 0 + 1 + 2 + 3 + 4 const initialValue = 0; // expected output: 10 const sumWithInitialTest = array1.reduce( (pv, cv) => { return pv + cv } ) console.log(sumWithInitialTest)

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!