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

157
Views
How to make sum function passing arguments through return function?

This is a simplified version with addition of 2 numbers:

const sum = (a) => {
  return function(b) {
    return a + b;
  }
}

console.log(
  sum(2)(2)
);

This is a more difficult option.

I couldn't find this problem on google, but I'm just wondering how to solve this. I couldn't think of a solution.

const sum = (a) => {
  // How to make it?
}

console.log(
  sum(2)(2)(4)() // Expected result: 8
  sum(2)(2)(4)(4)(4)() // Expected result: 16
  sum(2)(2)(4)(10)(20)(1)() // Expected result: 39
);

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!