Answers for "javascript get index of max value in array"

3

how to find index of max number in js

var a = [0, 21, 22, 7];
var indexOfMaxValue = a.reduce((iMax, x, i, arr) => x > arr[iMax] ? i : iMax, 0);

document.write("indexOfMaxValue = " + indexOfMaxValue); // prints "indexOfMaxValue = 2"
Posted by: Guest on August-21-2020
1

how to get index of max n values in an array

In [1]: import numpy as np

In [2]: arr = np.array([1, 3, 2, 4, 5])

In [3]: arr.argsort()[-3:][::-1]
Out[3]: array([4, 3, 1])
Posted by: Guest on July-04-2020
0

javascript index of biggest number

arr.indexOf(Math.max(...arr))
Posted by: Guest on December-20-2019

Code answers related to "javascript get index of max value in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language