Last active
June 17, 2024 09:12
-
-
Save HichamBenjelloun/be142d1b58461b3c8d7acce8525f6ef0 to your computer and use it in GitHub Desktop.
Generic sum function
This file contains hidden or 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
const sum = (...args) => | |
Object.assign( | |
sum.bind(null, ...args), | |
{valueOf: () => args.reduce((acc, cur) => acc + cur, 0)} | |
); | |
export default sum; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage :