Created
October 31, 2022 00:13
-
-
Save mogeko/573fb71bdfd2dda62610cc85b8d02a39 to your computer and use it in GitHub Desktop.
Revisions
-
mogeko created this gist
Oct 31, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /** * This function sums the given numbers. * * @param xs - The array to be calculated * @returns The sum of all elements in the number array * * @example * ```typescript * sum(); // 0 * sum([1, 2, 3]); // 6 * ``` */ export function sum(...xs: number[]) { return xs.reduce((a, b) => a + b, 0); }