Answers for "how to find the largest number 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
0

get largest no in the array javascript

//For Values
var arr =[1,10,3]
var min = Math.min.apply(null, arr),
    max = Math.max.apply(null, arr);

//For Objects
var arr = [{a: 1},{a: 10},{a: 3}]
var values = arr.map(val => val.a);
var max = Math.max.apply(null, values);
console.log(max)
Posted by: Guest on June-02-2021
0

Math method to find largest number in javaScript

Math.max()
Math.max(value0)
Math.max(value0, value1)
Math.max(value0, value1, ... , valueN)
Posted by: Guest on June-14-2021

Code answers related to "how to find the largest number javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language