javascript
\n\nconst countMatches = (items, ruleKey, ruleValue) => {\n  const i = { type: 0, color: 1, name: 2 }[ruleKey];\n\n  return items.filter((item) => item[i] === r
```\n\nconst countMatches = (items, ruleKey, ruleValue) => {\n  const i = { type: 0, color: 1, name: 2 }[ruleKey];\n\n  return items.filter((item) => item[i] === ruleValue).length;\n};\n\n```
['JavaScript']