How to find max and min of a subset of an array in Node.js

1 Answer

0 votes
const arr = [1, 3, 17, 6, 2, 88, 5, 4];

const max = Math.max(...arr.slice(1, 5)); // [ 3, 17, 6, 2 ]
console.log(max);

const min = Math.min(...arr.slice(1, 5));
console.log(min);



/*
run:

17
2

*/

 



answered Jul 20, 2024 by avibootz

Related questions

1 answer 86 views
1 answer 131 views
1 answer 153 views
1 answer 156 views
1 answer 121 views
2 answers 160 views
...