-
Notifications
You must be signed in to change notification settings - Fork 0
/
clase19.js
64 lines (51 loc) · 1.12 KB
/
clase19.js
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
var sacha = {
nombre: 'Sacha',
apellido: 'Lifszyc',
altura: 1.72
}
var alan = {
nombre: 'Alan',
apellido: 'Perez',
altura: 1.86
}
var martin = {
nombre: 'Martin',
apellido: 'Gomez',
altura: 1.85
}
var dario = {
nombre: 'Dario',
apellido: 'Juarez',
altura: 1.71
}
var vicky = {
nombre: 'Vicky',
apellido: 'Zapata',
altura: 1.56
}
var paula = {
nombre: 'Paula',
apellido: 'Barros',
altura: 1.76
}
const esAlta = ({ altura }) => altura > 1.8
var personas = [sacha, alan, martin, dario, vicky, paula]
var personasAltas = personas.filter(esAlta)
// var personasAltas = personas.filter(function (persona) {
// return persona.altura > 1.8
// })
// persona.altura = persona.altura * 100
const pasarAlturaACms = persona => {
return {
...persona,
altura: persona.altura*100
}
}
// Si el arrow Function empieza con paréntesis debe estar
// seguido de llaves y retornara el objeto al interior
const pasarAlturaACms = persona => ({
...persona,
altura: persona.altura * 100
})
var personasCms = personas.map(pasarAlturaACms) // Nota: map siempre devuelve un nuevo array
console.log(personasCms)