Count Vowel Substrings of a String LeetCode solution in JavaScript
1/**2* @param {string} word3* @return {number}4*/5var isVowel = function (c) {6return c === "a" || c === "e" || c === "i" || c === "o" || c === "u";7};89var countVowelSubstrings = function (word) {10let vowelMap = new Map();11let total = 0;12let totalLen = word.length - 1;13for (let i = 0; i <= totalLen; i++) {14vowelMap.clear();15for (let j = i; j <= totalLen && isVowel(word[j]); j++) {16vowelMap.set(word[j], (vowelMap.get(word[j]) ?? 0) + 1);17if (vowelMap.size == 5) total++;18}19}20return total;21};