FunctionRacerProblemsRace

Vowel and Consonant Tally

BeginnerStringsPython, JavaScript, TypeScript, Java, C++

s is a text that may hold letters of either case, digits, spaces and punctuation. Count its vowels and its consonants and return them as a two-item list [vowels, consonants].

The vowels are a e i o u in either case. Every other letter, including y, is a consonant. Characters that are not letters count as neither. An empty s gives [0, 0].

Example 1

s "Hello, World!"
returns [3,7]

The vowels are e, o, o and the consonants are H, l, l, W, r, l, d; the comma, the space and the ! count as neither.

Example 2

s "rhythm 42"
returns [0,6]

y is a consonant, so rhythm has six consonants and no vowel; the digits are ignored.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems