Pages

code : entrainement

 const students = [

  { studentname: "Alice", type: "l2info", mark: 15 },
  { studentname: "Bob", type: "DDI", mark: 8 },
  { studentname: "Charlie", type: "DDD", mark: 18 },
  { studentname: "David", type: "l2info", mark: 12 },
  { studentname: "Eve", type: "DDI", mark: 2 },
];

Donnez le code pour obtenir la liste des étudiants aux rattrapages

{ L3: [ { studentname: 'Alice', type: 'l2info', mark: 15 }, { studentname: 'Charlie', type: 'DDD', mark: 18 }, { studentname: 'David', type: 'l2info', mark: 12 } ], session2: [ { studentname: 'Bob', type: 'DDI', mark: 8 }, { studentname: 'Eve', type: 'DDI', mark: 0 } ] }

Partez d'un object vide
Puis définisez les clefs avec : key = student.mark >= 10 ? "L3" : "session2";

Object.groupBy(students,({ mark })=> {
    return mark >= 10 ? "L3" : "session2";
  });