Answers for "maximum 2 numbers in array js"

2

Find the maximum number of an array js

var arr = [1, 2, 3];
var max = arr.reduce(function(a, b) {
  return Math.max(a, b);
});
Posted by: Guest on October-22-2020
0

js find all max number indexes in array

const arr = [0,1,4,3,4];
const max = Math.max(...arr);
let res = [];
arr.forEach((item, index) => item === max ? res.push(index): null);
console.log(res);
Posted by: Guest on December-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language