Answers for "max index array javascript"

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

js max array

Math.min(...arr) // min
Math.max(...arr) // max
Posted by: Guest on August-24-2021
0

javascript index of biggest number

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

Code answers related to "max index array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language