[JavaScript] Easy to understand - 1 line
The core strategy for this problem is straightforward:\n- traverse the list\n- check each word is with a given prefix\n\nI guess there won\'t be any problem wit
The core strategy for this problem is straightforward:\n- traverse the list\n- check each word is with a given prefix\n\nI guess there won\'t be any problem with how to do the traversal. So, the only problem is how to check the prefix?\n\nWe could use `RegExp`, `indexOf`, `startsWith`, or even `slice` the first part.\nJust choose anyone you like, here are 2 samples from me:\n\n## Sample 1\n\n```js\nconst prefixCount = (words, pref) => {\n  let count = 0;\n  for (const word of words) {\n    word.startsWith(pref) && ++count;\n  }\n  return count;\n}\n```\n\n## Sample 2\n\n```js\nconst prefixCount = (words, pref) => words.filter(word => word.startsWith(pref)).length;\n```
['JavaScript']