-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter.js
More file actions
34 lines (30 loc) · 716 Bytes
/
Copy pathfilter.js
File metadata and controls
34 lines (30 loc) · 716 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
const arr = [
{
name: 'Lek',
age: 31
},
{
name: 'Ranju',
age: 31
},
{
name: 'Ritu',
age: 3
}
]
// console.log(arr)
let filterResult = arr.filter((item, index) => {
return item.age === 31
})
if(filterResult) {
console.log(filterResult)
} else {
console.log('Not found')
}
/*
* ----------------------------------------------------------------------------------------
* The filter() method creates a new array filled with elements that pass a test provided by a function.
* The filter() method does not execute the function for empty elements.
* The filter() method does not change the original array.
* ----------------------------------------------------------------------------------------
*/