Efficient one-liner solution with startsWith and reduce
Code\n\n/**\n * @param {string[]} words\n * @param {string} s\n * @return {number}\n */\nvar countPrefixes = function(words, s) {\n    return words.reduce((acc,
# Code\n```\n/**\n * @param {string[]} words\n * @param {string} s\n * @return {number}\n */\nvar countPrefixes = function(words, s) {\n    return words.reduce((acc, word) => s.startsWith(word) ? acc + 1 : acc, 0);\n};\n```
['JavaScript']