score:0

Accepted answer
const self = [];
const others = [];

all_items.forEach(item => {
  if (item.owner === current_user) {
    self.push(item);  
  } else {
    others.push(item);
  }
});

score:0

var all_items = [{
    id: 0,
    owner_id: 1, 
    name: "Matt",
},
{
    id: 1,
    owner_id: 2, 
    name: "Dave",
},
{
    id: 2,
    owner_id: 1, 
    name: "Mike",
},
{
    id: 3,
    owner_id: 3, 
    name: "Jack",
},
{
    id: 4,
    owner_id: 1, 
    name: "Paul",
}];

var current_user = {
    id: 1
};

// self
console.log(all_items.filter(function(item){
    return item.owner_id === current_user.id;
}));

// others
console.log(all_items.filter(function(item){
    return item.owner_id !== current_user.id;
}));

score:1

const group = () => {
  const items = [
 {
    id: 0,
    owner_id: 1, 
    name: "name",
},
 {
    id: 2,
    owner_id: 2, 
    name: "user 2",
}
];
let current_user = { id: 1, name: "current user"}

const result = items.filter(item => item.owner_id != current_user.id);
const result2 = items.filter(item => item.owner_id == current_user.id);

  return { result, result2}
}

Related Query

More Query from same tag