Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

count object based on status and shop using javascript

const items = [[
  {
    "id": 1,    
    "status": "ORANGE",
    "Shop":"ABC"
  },
  {
    "id": 2,
    "status": "GREEN",
    "Shop":"ABC"
  },
]

const itemsWithCount = items.map(item => ({
  ...item,
  Count: items.filter(({ status, Shop }) => item.status === status && item.Shop === Shop).length
}));
 
PREVIOUS NEXT
Tagged: #count #object #based #status #shop #javascript
ADD COMMENT
Topic
Name
8+1 =