Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array reduce and count based on proeperty js

const array = [
  {id: 12, name: 'toto'},
  {id: 12, name: 'toto'},
  {id: 42, name: 'tutu'},
  {id: 12, name: 'toto'},
];

const id = 12;
const count = array.filter((obj) => obj.id === id).length;

console.log(count);
 
PREVIOUS NEXT
Tagged: #array #reduce #count #based #proeperty #js
ADD COMMENT
Topic
Name
8+3 =