I'm attempting to extract specific values from an object with the status of 'xyz'
user.friends =
CoreMongooseArray [
{ _id: 5b11824350c0011afe9ca310,
user:
{ profile: [Object],
_id: 5b11805a50c0011afe9ca2fe,
username: 'user1' },
status: 'abc' },
{ _id: 5b191033d240ab4a10ffb54f,
user:
{ profile: [Object],
_id: 5b0ec81f958f5b4919b83c40,
username: 'user2' },
status: 'xyz' } ]
I am utilizing
user.friends.reduce((a, t) => a + (t.type === 'xyz' ? 0 : 1), 0);
However, instead of only returning the object with the username user2 like I expect, it is only returning 1. Why is this happening?