Skip to content

Instantly share code, notes, and snippets.

@stand-sure
Created May 27, 2020 18:01
Show Gist options
  • Save stand-sure/27131e46a693656abb03b14a29570163 to your computer and use it in GitHub Desktop.
Save stand-sure/27131e46a693656abb03b14a29570163 to your computer and use it in GitHub Desktop.
sums an arbitrary number of arguments
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