Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getStudentTopNotes(students) {
- const getMax = arr => arr.reduce( (acc, item) => acc >= item ? acc : item, 0);
- let [{notes: a},{notes: b}, {notes: c}] = students;
- let maxA, maxB, maxC;
- if(a == []) {
- maxA = 0;
- } else {
- maxA = getMax(a);
- }
- if(b == []) {
- maxB = 0;
- } else {
- maxB = getMax(b);
- }
- if(c == []) {
- maxC = 0;
- } else {
- maxC = getMax(c);
- }
- return [maxA,maxB,maxC]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement