VDL Plugin SDK

sum

Import from @varavel/vdl-plugin-sdk/utils/math.

function sum(nums): number;

Calculates the sum of an array of numbers.

This function takes an array of numbers and returns the sum of all the elements in the array.

Parameters

ParameterTypeDescription
numsreadonly number[]An array of numbers to be summed.

Returns

number

The sum of all the numbers in the array.

Example

const numbers = [1, 2, 3, 4, 5];
const result = sum(numbers);
// result will be 15