sum

math

Computes the sum of the values in array.

Signature

sum(array: number[]): number

Parameters

NameTypeDescription
arraynumber[]The array to iterate over

Returns

number - Returns the sum

Examples

Basic usage

import { sum } from 'dashlite'

const result = sum([4, 2, 8, 6])
console.log(result)

Output:

20

Empty array

import { sum } from 'dashlite'

const result = sum([])
console.log(result)

Output:

0

Available since version 1.0.0