7 kyu · reference

Vowel Count

StringsFundamentals

Return the number (count) of vowels in the given string.

We will consider a, e, i, o, u as vowels for this Kata (but not y).

The input string will only consist of lower case letters and/or spaces.

Solutions

01-solution.jsView on GitHub ↗
const vowels = ['a', 'e', 'i', 'o', 'u'];

function getCount(str) {
	return str.split('').reduce((count, char) => {
		if (vowels.includes(char.toLowerCase())) {
			return (count += 1);
		} else {
			return count;
		}
	}, 0);
}