I have the following object, Please let me know how to iterate over this object to get the count/length
of the property(category)
value to know how many times it is repeated.
like:
FIRST is repeated one-time(i.e count or length: 1)
SECOND is repeated three times(i.e count or length: 3)
THIRD is repeated three times(i.e count or length: 3)
FOURTH is repeated one-time (i.e count or length: 1)
var categorycount =
[{"name":"ABC","vals":[{"description":"first description","category":"FIRST"},
{"description":"second description","category":"SECOND"},
{"description":"third description","category":"SECOND"},
{"description":"fourth description","category":"SECOND"},
{"description":"fifth description","category":"THIRD"},
{"description":"sixth description","category":"THIRD"},
{"description":"eighth description","category":"THIRD"},
{"description":"ninth description","category":"FOURTH"},
]}];
var obj = JSON.stringify(categorycount[0].vals);
console.log(obj);