Files
30-seconds-of-code/snippets/countVowels.md
Stefan Feješ d8c41260da Add countVowels
2017-12-18 20:07:44 +01:00

291 B

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.

const countVowels = str =>
  return (str.match(/[aeiou]/ig) || []).length;
// countVowels('foobar') -> 3
// countVowels('gym') -> 0