How can I print the student with the highest grade and the student with the lowest grade of this JSON?

3

I need help in this exercise and I need to print the name of the student with the highest grade, and the student with the lowest grade of the next JSON:

/*
   est == estudiantes,
   5.0 == Nota Maxima,
   0.0 == Nota Minima 
*/

var est = [     
    {
        "Codigo": "001",
        "Nombre": "Juan",
        "Nota": 4.0
    }, {
        "Codigo": "002",
        "Nombre": "Felipe",
        "Nota": 4.5
    }, {
        "Codigo": "003",
        "Nombre": "Wilber",
        "Nota": 4.8
    }, {
        "Codigo": "004",
        "Nombre": "Andres",
        "Nota": 2.6
    }, {
        "Codigo": "005",
        "Nombre": "Kelly",
        "Nota": 5.0
    }, {
        "Codigo": "006",
        "Nombre": "Johana",
        "Nota": 3.4
    }, {
        "Codigo": "007",
        "Nombre": "Jaime",
        "Nota": 3.7
    }, {
        "Codigo": "008",
        "Nombre": "Maria",
        "Nota": 1.5
    }, {
        "Codigo": "009",
        "Nombre": "Esteban",
        "Nota": 2.8
    }, {
        "Codigo": "0010",
        "Nombre": "Clara",
        "Nota": 0.9
    }
];

So far I do not know how to do it .. Help please!

    
asked by Juan Felipe 22.02.2018 в 04:14
source

1 answer

6

you can sort the array according to the note and then show the first and last element of the ordered array:

est.sort(function(a, b){return a.Nota- b.Nota});
est.sort();
console.log(est[0].Nota);
console.log(est[est.length-1].Nota);

I hope it serves you. Greetings.

    
answered by 22.02.2018 в 04:38