-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmap.js
52 lines (42 loc) · 1.3 KB
/
map.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
import { students } from "./data/sample_data.js";
// const studentNames = students.map(function (student) {
// return {
// fullname: `${student.name} ${student.lastname}`,
// }
// })
// const studentCourses = students.map(function (student) {
// return {
// course: "Programming"
// }
// })
// const studentNames = students.map((student) => {
// return {
// fullname: `${student.name} ${student.lastname}`,
// };
// });
// const doubleAges = students.map((student) => student.age).map((age) => age * 2);
// const studentsInfo = students.map((student) => {
// return {
// fullname: `${student.name} ${student.lastname}`,
// age: student.age
// };
// });
// const texts = studentsInfo.map((student) => {
// return `${student.fullname} is ${student.age} years old`;
// })
// const texts = students
// .map((student) => ({
// fullName: `${student.name} ${student.lastname}`,
// age: student.age,
// }))
// .map((student) => `${student.fullName} is ${student.age} years old`);
// const fullnames = students.map(function (student) {
// return student.name + ' ' + student.lastname;
// })
const doubleage = students
.map((student) => ({
...student,
course: "Programming",
}))
.map((student) => ({ ...student, age: student.age * 2 }));
console.log(doubleage);