JSFiddle - React, Tailwind, and code Playground
JavaScript
function sum(initialValues) {
let currentSum = initialValues || 0;
function addNextValue(nextValue){
currentSum += nextValue
return addNextValue
}
addNextValue.getResult = function() {
return currentSum;
}
return addNextValue
}
console.log(sum(10)(20)(30)(40)(50));