forked from Leiber7/cursomongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathejercicio-MongoDB-estudiantes.js
More file actions
83 lines (71 loc) · 1.9 KB
/
Copy pathejercicio-MongoDB-estudiantes.js
File metadata and controls
83 lines (71 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var lista = [
{
id: 1,
nombre: 'Camila Lopez',
detalles: {
descripcion: 'matricula normal',
contacto: {
email: 'clopez@mail.com',
telefono: 83242834
},
valorMatricula: 200000
},
},
{
id: 2,
nombre: 'Pedro Perez',
detalles: {
descripcion: 'beca',
contacto: {
email: 'pperez@mail.com',
telefono: 83242834
},
valorMatricula: 0
},
},
{
id: 3,
nombre: 'Juan Yarce',
detalles: {
descripcion: 'matricula normal',
contacto: {
email: 'jyarce@mail.com',
telefono: 1122334455
},
valorMatricula: 400000
},
},
{
id: 4,
nombre: 'Alberto Benitez',
detalles: {
descripcion: 'matricula condicional',
contacto: {
email: 'abenitez@mail.com',
telefono: 234534566
},
valorMatricula: 600000
},
},
];
//suma de Valor Matricula
var valorMatriculas = lista.map((estudiante) => estudiante.detalles.valorMatricula);
var suma = valorMatriculas.reduce((uno, dos) => {
return uno + dos;
});
// fin valor matricula
//datos de contacto
var contactos = lista.map((estudiante) => estudiante.detalles.contacto);
//fin de contacto
//Nombre con mayor matricula
var ValoresMatricula = lista.map((estudiante) => estudiante.detalles.valorMatricula);
ValoresMatricula.reverse()
var nombre = lista.find((estudiante) => estudiante.detalles.valorMatricula == ValoresMatricula[0]).nombre;
//fin matricula
//correo estudiante matricula condicional
var matriculacondicional = lista.find((estudiante) => estudiante.detalles.descripcion == 'matricula condicional').detalles.contacto.email;
// fin matricula condicional
console.log (suma);
console.log (contactos);
console.log(nombre);
console.log(matriculacondicional);