-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.js
More file actions
39 lines (34 loc) · 701 Bytes
/
Copy pathmap.js
File metadata and controls
39 lines (34 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
35
36
37
38
39
const arr = [
{
name: 'Lek',
age: 31
},
{
name: 'Ranju',
age: 31
},
{
name: 'Ritu',
age: 3
}
]
// console.log(arr)
let newMapArr = arr.map((item, index) => {
return {
...item,
place: 'Kerala'
}
})
if(newMapArr) {
console.log(newMapArr)
} else {
console.log('Not found')
}
/*
* --------------------------------------------------------------------------
* map() creates a new array from calling a function for every array element.
* map() calls a function once for each element in an array.
* map() does not execute the function for empty elements.
* map() does not change the original array.
* --------------------------------------------------------------------------
*/