How to get the index of the max value in an array in Node.js

1 Answer

0 votes
const arr = [4, 8, 12, 7, 18, 10, 6, 9, 5];

const index = arr.indexOf(Math.max(...arr));

console.log(index);




/*
run:
  
4
  
*/

 



answered Jul 8, 2022 by avibootz

Related questions

1 answer 124 views
1 answer 164 views
1 answer 178 views
1 answer 149 views
1 answer 140 views
2 answers 174 views
...