I would like to know how i can count the number of occurences on an array of object like this one :
[
{id : 12,
name : toto,
},
{id : 12,
name : toto,
},
{id : 42,
name : tutu,
},
{id : 12,
name : toto,
},
]
in this case i would like to have a function who give me this :
getNbOccur(id){
//don't know...//
return occurs;
}
and if i give the id 12 i would like to have 3.
How can i do that?