0

I need to remove an object according to one of it's properties, the object is inside of an array within another array, this is my attempt which is not working:

listArray.forEach(function(entry) {
        entry.forEach(function(entry) {
            toDelete = $.grep(entry, function(a) {
                return a = 'theValue';
            });
            delete toDelete;
        });
    });

Here is a JSFiddle: http://jsfiddle.net/p95qL/

Matt Starkey
  • 69
  • 1
  • 4
  • Do you get any errors or anything? – Sumner Evans Mar 31 '14 at 19:47
  • 2
    Well first off, I think you meant to use `==` instead of `=` inside your inner function. – p.s.w.g Mar 31 '14 at 19:47
  • Don't use `entry` as the argument twice. It confuses matters. – Andy Mar 31 '14 at 19:47
  • 2
    `$.grep` returns a new Array of the filtered set, and that's not a proper use of `delete` anyway. You should simply use `$.grep` to overwrite the old Array with a new one that has the objects removed. – cookie monster Mar 31 '14 at 19:47
  • If you can provide a fiddle of some sample data we might come up with some better solutions for you. – Andy Mar 31 '14 at 19:48
  • I know a lot of users tell you to post a jsFiddle. What you need to do is post all relevant data directly in the question, and post an off-site demo only in addition. – cookie monster Mar 31 '14 at 21:06

0 Answers0