Answers for "math.js find largest value in array"

5

javascript hwo to return largest value with index

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
0

Return the highest number in Arrays in JavaScript

function largestOfFour(arr) {
  return arr.map(Function.apply.bind(Math.max, null));
}
Posted by: Guest on December-08-2021

Code answers related to "math.js find largest value in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language