forked from DouglasHdezT/JavaScript_NodeCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample5.js
More file actions
34 lines (26 loc) · 701 Bytes
/
Example5.js
File metadata and controls
34 lines (26 loc) · 701 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
/**
* Map; Apply a function to every item in an array, returning a new array with the items modified; Returns a new instance of Array
*/
let numbers = [1, 2, 3, 4, 5];
let people = [
{name: "Douglas", lastname: "Hernandez"},
{name: "Pedro", lastname: "Gomez"},
]
const arrayTimesX = x => {
let newArray = numbers.map(element => {
return element * x;
});
console.log(newArray);
}
const listFullnames = () => {
let fullnames = people.map(element => {
let fullname = `${element.name} ${element.lastname}`;
return fullname;
});
console.log(fullnames);
}
arrayTimesX(2);
arrayTimesX(3);
arrayTimesX(4);
arrayTimesX(5);
listFullnames();