generated from oveland/react_vite_tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestMap.js
34 lines (30 loc) · 1.1 KB
/
testMap.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
const names = ['john', 'jane', 'alice'];
// Usa map para convertir los nombres a mayúsculas
// Salida esperada: ['JOHN', 'JANE', 'ALICE']
names.map((name) => {
const nameUpperCase = name.toUpperCase();
console.log(nameUpperCase);
});
//************************exercise two **************************************
const pricesInDollars = [10, 20, 30, 40];
const exchangeRate = 0.85;
// Usa map para convertir los precios a euros
// Salida esperada: [8.5, 17, 25.5, 34]
const priceEuros = pricesInDollars.map((dollar) => {
const echange = dollar * exchangeRate;
return echange;
});
//************************exercise three **************************************
const books = [
{ title: 'Book 1', author: 'Author 1', year: 2001 },
{ title: 'Book 2', author: 'Author 2', year: 2002 },
{ title: 'Book 3', author: 'Author 3', year: 2003 },
];
// Usa map para extraer solo los títulos de los libros
// Salida esperada: ['Book 1', 'Book 2', 'Book 3']
const booksTitles = books.map((book) => {
const tittle = book.title;
return tittle;
});
console.log('Euros', priceEuros);
console.log('TITLES', booksTitles);