Created
November 18, 2018 12:48
-
-
Save harrisonmalone/d007f0605695ebee74fbdbb5946d6db0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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