How to find the min and max of an int array in TypeScript

1 Answer

0 votes
const array: number[] = [8, 14, 4, 2, 5, 96, 2, 6, 89, 3,  7];

const min: number = Math.min(...array);
const max: number = Math.max(...array);
 
console.log(`Minimum: ${min}`);
console.log(`Maximum: ${max}`);



/*
run:

"Minimum: 2" 
"Maximum: 96" 

*/

 



answered Jan 16, 2025 by avibootz
edited Jan 16, 2025 by avibootz
...