(str)
| 8 | */ |
| 9 | |
| 10 | const countVowels = (str) => { |
| 11 | if (typeof str !== 'string') { |
| 12 | throw new TypeError('Input should be a string') |
| 13 | } |
| 14 | |
| 15 | const vowelRegex = /[aeiou]/gi |
| 16 | const vowelsArray = str.match(vowelRegex) || [] |
| 17 | |
| 18 | return vowelsArray.length |
| 19 | } |
| 20 | |
| 21 | export { countVowels } |