Quick one, I've 2 arrays/ objects. One contains all items the other contains selected ID's from the first array. 

My question is, what is the best way to loop through both arrays find selected items from the second array and if they are true append data to first array. What I'm trying to do is append true to the first array if the ID's match. 

For example something like this: 

```
this.categories.filter(
                        category => {

                            this.user.category_ids.filter(
                                selected => {
                                    if(selected == category._id) {
                                        var data = {'selected': true};

                                        category.push(data);
                                    }
                                }
                            );

                            console.log(category);
                        }
                    );

```

At the moment I'm looping through categories object then through user.category\_ids and if the ID's match I want to append selected: true to first array object, if this makes sense. I get error:

```
core.es5.js:1084 ERROR TypeError: category.push is not a function

```

Which I don't understand why. I've also tried splice. 

Also to me this doesn't seem like best approach, because I've 12 items in first array. And if all 12 are selected, second array will have 12 items. So looping through 12 \* 12 to me is little expensive, memory wise.