re: Daily Challenge #3 - Vowel Counter VIEW POST

FULL DISCUSSION
 

I like to be explicit about types with these sorts of functions, and I assume Set is fast at looking up whether something belongs to it.

const vowels = new Set('aeiou');

const countVowels = (input) =>
      [...String(input).toLocaleLowerCase()].reduce(
        (count, character) => (vowels.has(character)
                               ? count + 1
                               : count),
        0);

console.log(countVowels('This is a TEST'));
code of conduct - report abuse