Skip to content

Instantly share code, notes, and snippets.

@ptkato
Last active February 27, 2016 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptkato/8dc826739d4038e3bff2 to your computer and use it in GitHub Desktop.
Save ptkato/8dc826739d4038e3bff2 to your computer and use it in GitHub Desktop.
A thing.
alunos = [{nome:"Nilmar",notas:[2.5,6,6]},{nome:"Gustavo",notas:[6,4.5,7]},{nome:"Alexandre",notas:[10,10,0]},{nome:"Lionel Messi",notas:[5.9,5.9,5.9]}]
aprovados = alunos.filter(function(x) {
return (x.notas.sort(function(a, b) {
return a - b;
}).splice(0, 2).reduce(function(y, z) {
return y + z;
}) / 2) >= 6;
});
console.log(aprovados);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment