forked from mehediislamripon/Problem-solving-with-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem-14.js
More file actions
21 lines (17 loc) · 642 Bytes
/
Copy pathproblem-14.js
File metadata and controls
21 lines (17 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// removeArrayElement("money") returns the array without the money object
// removeArrayElement("id") returns the array without the id object
// removeArrayElement("cStatus") returns the array without the cStatus object
const array = [
{ field: 'id', operator: 'eq' },
{ field: 'cStatus', operator: 'eq' },
{ field: 'money', operator: 'eq' },
];
const filterField = 'money';
function removeArrayElement(filterField) {
// write your solution here
let result = array.filter(function (obj) {
return obj.field !== filterField;
});
return result;
}
console.log(`filtered array: ${removeArrayElement(filterField)}`);