reduce 2
reduce 3
reduce 4
Amélioration
const words = [0,2,0,0,6];
let t = words.reduce(function( {max, min}, x) {
min = Math.min(min,x);
max = Math.max(max,x);
return { min, max }
},
{min : Number.MAX_VALUE,
max : Number.MIN_VALUE,
});
const nbOccurences = words.reduce((a, x) => {
a[x]= a[x]+1;
return a},Array.from({length:t.max+1},()=>0));