Files
30-seconds-of-code/snippets_archive/countVowels.md
Angelos Chalaris 611729214a Snippet format update
To match the starter (for the migration)
2019-08-13 10:29:12 +03:00

325 B

title, tags
title tags
countVowels string,beginner

Retuns number of vowels in provided string.

Use a regular expression to count the number of vowels (A, E, I, O, U) in a string.

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