1const array = [
2 {
3 username: "john",
4 team: "red",
5 score: 5,
6 items: ["ball", "book", "pen"]
7 },
8 {
9 username: "becky",
10 team: "blue",
11 score: 10,
12 items: ["tape", "backpack", "pen"]
13 },
14 {
15 username: "susy",
16 team: "red",
17 score: 55,
18 items: ["ball", "eraser", "pen"]
19 },
20 {
21 username: "tyson",
22 team: "green",
23 score: 1,
24 items: ["book", "pen"]
25 },
26
27];
28//FILTER MEMBERS IN TEAM "RED"
29const filterArray=array.filter(word=>word.team==="red")
1var PATTERN = /bedroom/,
2 filtered = myArray.filter(function (str) { return PATTERN.test(str); });
3
1const filterThisArray = ["a","b","c","d","e"]
2console.log(filterThisArray) // Array(5) [ "a","b","c","d","e" ]
3
4const filteredThatArray = filterThisArray.filter((item) => item!=="e")
5console.log(filteredThatArray) // Array(4) [ "a","b","c","d" ]
6
1var data = [
2 {email: "usera@gmail.com",nama:"User A", Level:"Super Admin"},
3 {email: "userb@gmail.com",nama:"User B", Level:"Super Admin"},
4 {email: "userc@gmail.com",nama:"User C", Level:"Standart"},
5 {email: "userd@gmail.com",nama:"User D", Level:"Standart"},
6 {email: "usere@gmail.com",nama:"User E", Level:"Admin"},
7 {email: "userf@gmail.com",nama:"User F", Level:"Standart"}
8];
9var filter = "Level";
10var keyword = "Standart";
11
12var filteredData = data.filter(function(obj) {
13 return obj[filter] === keyword;
14});
15
16console.log(filteredData);