JavaScript, single pass O(n), one-liner (almost...)
javascript\nconst RULE_IDX = {\n    \'type\': 0,\n    \'color\': 1,\n    \'name\': 2\n};\n\nvar countMatches = function(items, ruleKey, ruleValue) {\n    return
```javascript\nconst RULE_IDX = {\n    \'type\': 0,\n    \'color\': 1,\n    \'name\': 2\n};\n\nvar countMatches = function(items, ruleKey, ruleValue) {\n    return items.reduce((ans, item) => item[RULE_IDX[ruleKey]] === ruleValue ? ans + 1 : ans, 0);\n};\n```
['JavaScript']