Skip to content

Instantly share code, notes, and snippets.

@lindsaycarbonell
Last active March 8, 2021 18:49
Show Gist options
  • Save lindsaycarbonell/cbf449dd9db7fb3f0c90cd76353f6dc1 to your computer and use it in GitHub Desktop.
Save lindsaycarbonell/cbf449dd9db7fb3f0c90cd76353f6dc1 to your computer and use it in GitHub Desktop.
kata: vowel count

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

We will consider a, e, i, o, and u as vowels for this Kata.

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

function getCount(str) {
return (str.match(/[aeiou]/ig)||[]).length;
}
function getCount(input) {
var vowelsCount = 0;
var inputLetters = input.split("");
const vowels = ["a","e","i","o","u"];
vowels.forEach(function(vowel) {
inputLetters.forEach(function(inpLetter) {
if (inpLetter === vowel) {
vowelsCount++;
}
});
});
return vowelsCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment