- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path37_array_filter.js
More file actions
Latest commit
26 lines (22 loc) · 705 Bytes
/
Copy path37_array_filter.js
File metadata and controls
26 lines (22 loc) · 705 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
// filter
// return new array
// can manipulate the size of new array
// return based on condition
letpeople=[
{name: 'john doe',born: 1983,position: 'senior developer'},
{name: 'bobo',born: 1987,position: 'developer'},
{name: 'peter',born: 1989,position: 'designer'},
{name: 'sussy',born: 1975,position: 'the boss'},
{name: 'Jane',born: 1999,position: 'the boss'},
];
constdeveloper=people.filter(function(items){
return(
items.position==='developer'||items.position==='senior developer'
);
});
console.log(developer);
constages=people.filter(function(items){
// yg kurang dari 1989 ada 3
returnitems.born<1989;
});
console.log(ages);