Skip to main content

.max_val_index()

A function that finds the maximimum value in an array and returns both the maximimum value and its index in the array. If multiple elements in the array are the maximum value, the index of the first maximum value will be used.

Syntax

#fs.scripts.lib().max_val_index(array);

Parameters

array

The array from which the maximimum value index should be extracted.

Return

Returns an array.

Example

function(context, args) {
const l = #fs.scripts.lib();
const my_array = [2001, 3006, 1337, 42, 7];

return l.max_val_index(my_array);
}