Answers for "how to return largest number in array javascript"

3

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
5

javascript largest number in array

const max = arr => Math.max(...arr);
Posted by: Guest on July-02-2020
10

javascript get array min and max

//get min/max value of arrays
function getArrayMax(array){
   return Math.max.apply(null, array);
}
function getArrayMin(array){
   return Math.min.apply(null, array);
}
var ages=[11, 54, 32, 92];
var maxAge=getArrayMax(ages); //92
var minAge=getArrayMin(ages); //11
Posted by: Guest on July-31-2019
8

get largest number in array javascript

const array1 = [1, 3, 2];

Math.max(...array1);
// expected output: 3
Posted by: Guest on August-07-2020
1

function that search a biggest value in array javascript

function maisBaratosQue(valor, precos) {
   return precos.filter(p => p <= valor);
}
Posted by: Guest on September-18-2020

Code answers related to "how to return largest number in array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language