I am working with an array of objects in AngularJS that looks like this:
var example = [ {id:'1',
read: false,
folder: 'inbox'},
{id:'2',
read: true,
folder: 'inbox'},
{id:'3',
read: true,
folder: 'trash'},
{id:'4',
read: false,
folder: 'trash'}];
My goal is to remove any object that contains both folder == 'trash'
and read == true
.
I attempted to achieve this using lodash:
example = lodash.filter(example, function(value, index) {
return (value.folder !== 'trash') && (value.read !== true);
});
However, instead of deleting only item #3, it removes both item #3 and item #4.
I seem to be misunderstanding how lodash.filter functions. Can someone please provide some guidance?