Skip to content

Tag: frequency

Count frequency of specific value in JavaScript object

I have a JavaScript object that is structured as such: var subjects = {all: “inactive”, firstSingular: “active”, secondSingular: “inactive”, thirdSingular: “active”, firstPlural: “inactive”, secondPlural: “inactive”, thirdPlural: “inactive” I would like to count the instances of the “active” value within this object (i.e return 2). I could certainly write a function that iterates through the object and counts the values, though