Skip to content

sum

Sum the elements of the array

ts
function sum(arr: number[]): any;

Usage

ts
import { sum } from 'rattail'

const arr = [1, 2, 3, 4, 5]
console.log(sum(arr)) // 15
console.log(sum([])) // 0

Arguments

ArgDescription
arrarray

Returns

The sum of the elements of the array