How to get the index of the max value in an array in TypeScript

1 Answer

0 votes
const arr: Array<number> = [4, 8, 3, 10, 5, 0, 9, 7]; 

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

console.log(index);




/*
run:
  
3
  
*/

 



answered Jul 8, 2022 by avibootz

Related questions

...