Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created November 18, 2018 12:48
Show Gist options
  • Save harrisonmalone/d007f0605695ebee74fbdbb5946d6db0 to your computer and use it in GitHub Desktop.
Save harrisonmalone/d007f0605695ebee74fbdbb5946d6db0 to your computer and use it in GitHub Desktop.
// 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) {
const strArr = str.split("")
let vowelsArr = []
strArr.forEach(function(letter) {
if (checkLetters(letter)) {
vowelsArr.push(letter)
}
})
vowelsArr = vowelsArr.length
return vowelsArr
}
function checkLetters(letter) {
const vowels = ['a','e','i','o','u']
let i = 0
while (i < vowels.length) {
if (vowels[i] === letter) {
return true
}
i++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment