Pages

Correction DS


  1. const moyenne = function (notes) {

  2.     return notes.reduce((acc, cur) => acc + cur) / notes.length;}


  3. const score = function (etudiant) {

  4.     return moyenne(etudiant.notes)}


  5. const notABS = function (etudiant) {

  6.     return etudiant.notes.every(note => note !== "ABS");}


  7. let etudiantsAclasser = etudiants.filter(notABS);

  8. let classement = etudiantsAclasser.map(function (etudiant) {

  9.     let nom = etudiant.nom

  10.       ,moyenne = score(etudiant);

  11.     return { nom, moyenne }});


  12. classement.sort(function (a, b) {

  13.     if (a.moyenne < b.moyenne) { return 1 }

  14.     else { return -1 }})


  15. classement.forEach(function (etudiant, rang) {

  16.     let current = etudiants.find(({ nom }) => nom == etudiant.nom);

  17.     current.rang = rang + 1;})



LAST CALL for DS

Students for DS 19/11 

please go to this reading