Created
February 4, 2021 05:43
-
-
Save randycasburn/6e7fd014a8d130f8ccb97453d3aa6ddd to your computer and use it in GitHub Desktop.
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 addTogether(...args) { | |
if (args.length > 2 || args.some(p => p.constructor !== Number)) return; | |
return args.length === 2 ? args[0] + args[1] : (n) => addTogether(args[0], n); | |
} | |
console.log(addTogether(2, 3)); | |
console.log(addTogether(2)(3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment