Maximum Number of Words You Can Type LeetCode solution in JavaScript
1var canBeTypedWords = function (text, brokenLetters) {2let regexp = "[" + brokenLetters + "]\+";3let word = text.split(" "),4count = 0;5for (let i = 0; i < word.length; i++) {6let work = true;7// if matches, means word[i] contains malfunction letters.8if (word[i].match(regexp)) {9work = false;10}11if (work) {12count++;13}14}15return count;16};