Created
May 27, 2020 18:01
-
-
Save stand-sure/27131e46a693656abb03b14a29570163 to your computer and use it in GitHub Desktop.
sums an arbitrary number of arguments
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
const sum: (...values: any[]) => number = (...values) => { | |
return values.reduce( | |
(total, val) => total + (isNaN(Number(val)) ? 0 : Number(val)) | |
); | |
}; | |
export { sum }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment