Révision


const words = [1,2,7];

const alphabetical = words.reduce((a, x) => {
   if (!a[x]) a[x] = 0;
   a[x]=a[x]+1;
return a},{});

-----------Donner la valeur de alphabetical ------------

const alphabetical = words.reduce((a, x) => {
   if (!a[x]) a[x] = 0;
   a[x]=a[x]+1;
return a},[]);

-----------Donner la valeur de alphabetical ------------


const words = [1,2,2,1,5];

let min = words.reduce((a, x) => Math.min(a,x));

console.log(min);

let max = words.reduce((a, x) => Math.max(a,x));

console.log(max);

let t = Array.from({length:max-min+1},()=>0);

console.log(t);

const alphabetical = words.reduce((a, x) => {
   a[x-1]= a[x-1]+1;
return a},t);

-----------Donner la valeur de alphabetical ------------


const words = [1,2,2,1,5];

let minMaxDistSumMoyNb = words.reduce((a, x) => {
   let [m,M] = [Math.min(a[0],x),Math.max(a[1],x)];
   let sum = a[3]+x;
   let nb = a[5]+1;
   let moy = sum/nb;
   return [m,M,M-m+1,sum,moy,nb]
}
,[Number.MAX_VALUE,Number.MIN_VALUE,Number.MIN_VALUE,0,0,0]);

-----------Donner la valeur de minMaxDistSumMoyNb) ---------------------