[JavaScript] Elegant solution using a set and reduce (with explanation)
It\'s a pretty straight forward solution. All we need to do is:\n- create a set containing all allowed characters,\n- iterate over all words using reduce accumu
It\'s a pretty straight forward solution. All we need to do is:\n- create a set containing all allowed characters,\n- iterate over all words using reduce accumulating the number of `good` words\n- split each word into the array of letters\n- check if `every` letter is present in a set of allowed words\n- if so - increment the accumulator\n- return accumulated value\n\n\n```javascript\nconst countConsistentStrings = (allowed, words) => {\n  let set = new Set(allowed)\n  return words.reduce((a, w) => {\n    return w.split(\'\').every(l => set.has(l)) ? ++a : a\n  }, 0)\n}\n```
['Ordered Set', 'JavaScript']