Maximum Number of Words You Can Type LeetCode solution in JavaScript

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

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0