This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(x){ | |
let sum = x; | |
function resultFn(y){ | |
sum +=y; | |
return resultFn; | |
} | |
resultFn.valueOf = function(){ return sum }; | |
return resultFn; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(x){ | |
return function (y){ | |
return x+y; | |
} | |
} | |
//ES6 version using arrow functions | |
const add = x=> y=>x+y; |
NewerOlder