I have to call function in below way
sum(3)(2)
My function is:
sum(a,b) { return a + b }
I have to call function in below way
sum(3)(2)
My function is:
sum(a,b) { return a + b }
Take a look at Currying concept
let sum = (a) => (b) => a + b
console.log(sum(1)(3)) // 4
you can try out this approach
function sum(x, y) {
 if (y !== undefined) {
  return x + y;
 } else {
  return function(y) { return x + y; };
 }
}
To understand it better https://www.toptal.com/javascript/interview-questions