// trouvez đ
const getRandomArray = (length) => {
return Array.from({ length }, () => Math.floor(Math.random() * 5));
};
getRandomArray(5); //
const arr = getRandomArray(5);
// give max
const max = Math.max( đ ); //
// give max with reduce
const maxWithReduce = arr.reduce( đ );
// give min and max with reduce
const minMaxWithReduce = arr.reduce(
đ ,
{ min: Infinity, max: -Infinity }
);
//use destructuring to get min and max
const { đ } = minMaxWithReduce;
console.log(min, maximum);
// give ocurrences of numbers in array
const occurrences = arr.reduce((acc, val) => {
đ );
console.log(occurrences);
Exemple d'affichage :