Say I have an array of objects called friends
let friends = [
{"name": "test 1", "type": "pending"},
{"name": "test 2", "type": "friends"},
{"name": "test 3", "type": "friends"},
{"name": "test 4", "type": "friends"},
{"name": "test 5", "type": "alien"}
]
how would I get the length of friends where pending would be excluded? I'm using this, but is there an easier way?
let total = friends.filter(friend=>friend.type==='friends').length + friends.filter(friend=>friend.type==='alien').length;