Answers for "javascript get max index of 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
4

js max value of array

let numbers = [4, 13, 27, 0, -5]; // Get max value of an array in Javascript

Math.max.apply(null, numbers); // returns 27
Posted by: Guest on March-25-2020
1

how to find max number in array javascript

const array1 = [1, 3, 2];
console.log(Math.max(...array1));
Posted by: Guest on June-22-2020

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language