❇ count-items-matching-a-rule👌 🏆O(1)❤️ Javascript🎯 Memory👀97.27%🕕 ++Explanation✍️ 🔴🔥 ✅ 👉
\nTime Complexity: O(N)\nSpace Complexity: O(1)\n\n\nvar countMatches = function (items, ruleKey, ruleValue) {\n    const categoryIndex = {\n        type: 0,\n 
![image](https://assets.leetcode.com/users/images/14d7dbcd-5e0b-46d3-87be-5ab66fa6e748_1712214098.9001987.png)\nTime Complexity: O(N)\nSpace Complexity: O(1)\n\n```\nvar countMatches = function (items, ruleKey, ruleValue) {\n    const categoryIndex = {\n        type: 0,\n        color: 1,\n        name: 2,\n    };\n    let count = 0;\n    for (let index = 0; index < items.length; index++) {\n        if (items[index][categoryIndex[ruleKey]] === ruleValue) {\n            count++;\n        }\n    }\n    return count;\n};\n```
[]