var countVowelSubstrings = function(word) { let str = 'aeiou'; let tmp = ''; let deo = []; for (let i = 0, n = word.length; i < n; i++) { if (str.includes(word[i])) { tmp += word[i]; } else { deo.push(tmp); tmp = ''; } } deo.push(tmp); deo = deo.filter((e) => e.length >= 5); if (deo.length == 0) { return0; } let count = 0; for (let m = 0; m < deo.length; m++) { let mon = deo[m]; for (let i = 0, n = mon.length; i < n; i++) { for (let j = i + 4; j < n; j++) { let ans = mon.slice(i, j + 1); if ( Array.from(newSet(ans.split(''))) .sort() .join('') === str ) { count++; } } } } return count; };