Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getStudentTopNotes(students) {
  2.  
  3.   const getMax = arr => arr.reduce( (acc, item) => acc >= item ? acc : item, 0);
  4.   let [{notes: a},{notes: b}, {notes: c}] = students;
  5.   let maxA, maxB, maxC;
  6.  
  7.   if(a == []) {
  8.     maxA = 0;
  9.   } else {
  10.     maxA = getMax(a);
  11.   }
  12.    if(b == []) {
  13.     maxB = 0;
  14.   } else {
  15.     maxB = getMax(b);
  16.   }
  17.    if(c == []) {
  18.     maxC = 0;
  19.   } else {
  20.     maxC = getMax(c);
  21.   }
  22.  
  23. return [maxA,maxB,maxC]
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement