Javascript O(n) very easy solution
\nconst countMatches = function(items, ruleKey, ruleValue) {\n    let count=0;\n    let index = -1;\n    if(ruleKey === \'type\')  index = 0;\n    if(ruleKey ==
```\nconst countMatches = function(items, ruleKey, ruleValue) {\n    let count=0;\n    let index = -1;\n    if(ruleKey === \'type\')  index = 0;\n    if(ruleKey === \'color\') index = 1;\n    if(ruleKey === \'name\')  index = 2;\n    \n    items.forEach(item =>{\n        if(item[index] === ruleValue) count++;\n    })\n    return count;\n};\n```
['JavaScript']