Answers for "array reduce and count based on proeperty js"

0

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);
Posted by: Guest on July-24-2020

Code answers related to "array reduce and count based on proeperty js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language