Search
 
SCRIPT & CODE EXAMPLE
 

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
}));
Comment

PREVIOUS NEXT
Code Example
Javascript :: Randomly getting error 500 in Azure App Service when downloading angularjs template 
Javascript :: AngularJS ui-select multiple should show alert if limit is crossed 
Javascript :: angularjs How to set code view as deafult instead of tree in jsoneditor 
Javascript :: angularjs Both ng-model and ng-change on input alter the $scope state - which one takes priority 
Javascript :: angularjs How to render either a number or a HTML element depending on what a function returns 
Javascript :: angularjs New Entry Not reflacting in table after inserting New record in CRUD angular app 
Javascript :: How to call keyup function on textbox for every dynamic generated form in Angular8 
Javascript :: angular chart js graph legend colors 
Javascript :: Presenting backend data using AngularJS/AJAX in MVC VIEW 
Javascript :: Filtering smart-table on transformed data 
Javascript :: Using animateCamera in functional components in react native 
Javascript :: adding text to ant media stream 
Javascript :: adding to an array in js 
Javascript :: track call recording in facebook using elements 
Javascript :: express and jade, ignore render errors 
Javascript :: mongodb create index json 
Javascript :: No enum constant datepicker react native 
Javascript :: laravel sending email to outlook link not working 
Javascript :: queryselector undefined not working in react js 
Javascript :: javascript object access time complexity 
Javascript :: yoptascript 
Javascript :: underscore js 
Javascript :: confirming the end javascript 
Javascript :: Accessing Function Declared Outside Constructor But Inside Class 
Javascript :: regex specific number of characters 
Javascript :: function titleCase 
Javascript :: javascript check if array has at least one true value 
Javascript :: Backbone Model Setting, Has And Getting 
Javascript :: auto load window on change viewport react 
Javascript :: Backbone Collection Example 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =