Add countVowels

This commit is contained in:
Stefan Feješ
2017-12-18 20:07:44 +01:00
parent 80f95a9661
commit d8c41260da

12
snippets/countVowels.md Normal file
View File

@ -0,0 +1,12 @@
### countVowels
Retuns `number` of vowels in provided string.
Use a regular expression to count number of vowels `(A, E, I, O, U)` in a `string`.
```js
const countVowels = str =>
return (str.match(/[aeiou]/ig) || []).length;
// countVowels('foobar') -> 3
// countVowels('gym') -> 0
```