@svizzle/utils/array-number

Methods

(static) arrayAverage(–) → {number}

Source:
Since:
  • 0.11.0

Return the average of the numbers in the provided array

Example
> arrayAverage([1, 23, 6])
10
> arrayAverage([])
0
Parameters:
Name Type Description
array

number[]

Returns:
Type
number

(static) arrayMax(array) → {number}

Source:
Since:
  • 0.1.0
See:

Return the max of the numbers in the provided array

Example
> arrayMax([-1, -2, 0, 1, 2])
2
Parameters:
Name Type Description
array array
Returns:

max

Type
number

(static) arrayMin(array) → {number}

Source:
Since:
  • 0.1.0
See:

Return the min of the numbers in the provided array

Example
> arrayMin([-1, -2, 0, 1, 2])
-2
Parameters:
Name Type Description
array array
Returns:

min

Type
number

(static) arraySum(array) → {number}

Source:
Since:
  • 0.3.0
See:

Return the sum of the numbers in the provided array

Example
> arraySum([1, -2, 3, -4, 5])
3
> arraySum([])
0
Parameters:
Name Type Description
array array
Returns:

sum

Type
number

(static) keyValueArrayAverage() → {number}

Source:
Since:
  • 0.11.0

Return the average of values of a {key, value}[] array

Example
> keyValueArrayAverage([
	{key: 'a', value: 1},
	{key: 'b', value: 23},
	{key: 'c', value: 6},
])
10
> keyValueArrayAverage([])
0
Parameters:
Type Description
array

{key, value}[]

Returns:
Type
number

(static) makeRandomNumInRange(range) → {number}

Source:
Since:
  • 0.1.0

Return a random number in the specified range.

Example
> makeRandomNumInRange(1.2, 7.4)
4.2
Parameters:
Name Type Description
range array
Returns:
Type
number