-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenges.js
More file actions
35 lines (29 loc) · 818 Bytes
/
challenges.js
File metadata and controls
35 lines (29 loc) · 818 Bytes
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
const { childrenAge, mailList, shopCart } = require("./data");
/**
* Adicione o ano de nascimento das crianças para cada elemento do array
*/
const children = childrenAge.reduce((list, age) => {
list.push({
age,
birthYear: 2019 - age
});
return [...list];
}, []);
/**
* Crie um array somente com os domínios da lista de email
*/
const domains = mailList.map(mail => {
const mailArray = mail.split("@");
return mailArray[1];
});
/**
* Encontre o maior preço dos produtos abaixo de 100 reais
*/
const bellow100 = shopCart
.filter(product => product.unitPrice <= 100)
.reduce((lastProductUnitPrice, currentProduct) => {
if (lastProductUnitPrice > currentProduct.unitPrice)
return lastProductUnitPrice;
return currentProduct.unitPrice;
}, 0);
console.table(bellow100);