Javascript | Easy to understand
\nvar countMatches = function(items, ruleKey, ruleValue) {\n    var ruleKeys =[\'type\',\'color\',\'name\'];\n     var keyIndex = ruleKeys.indexOf(ruleKey);\n  
```\nvar countMatches = function(items, ruleKey, ruleValue) {\n    var ruleKeys =[\'type\',\'color\',\'name\'];\n     var keyIndex = ruleKeys.indexOf(ruleKey);\n     var count=0;\n   for(var i=0;i<items.length;i++){\n       if(items[i][keyIndex]===ruleValue) count++;    \n   }return count\n};\n```
['JavaScript']