JSFiddle - React, Tailwind, and code Playground

JavaScript

function sum(a) {
  let count = 0;
  if(a !== undefined) {count += a;}
  return function help(b) {
    if (b === undefined) {
      return count;
    } else {
      count += b;
      return help;
    }
  }
}

console.log(sum());
console.log(sum(1)(2)() === 3);
console.log(sum(1)(2)(5)() === 8 );