Hope you’re ready for another challenge! Let’s get started with Day 3.
Today’s challenge is modified from user @jayeshcp on CodeWars.
Write a function that returns the number (count) of vowels in a given string. Letters considered as vowels are: a, i, e, o, and u. The function should be able to take all types of characters as input, including lower case letters, upper case letters, symbols, and numbers.
In this challenge, you should be able to efficiently ignore spaces and symbols and discern between capital and lowercase letters. Beginners can start with only lowercase letters and move up from there. It’ll definitely get you ready for tomorrow.
Happy coding!~
Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge for a future post? Email yo+challenge@dev.to with your suggestions!
Latest comments (82)
Ruby :
Clojure
Go:
function findVowelLetters(s){
var v = ["a","e","o","i","u"];
var vow = "";
var slowerCase = s.toLowerCase();
for(var f of v){
for(var i =0; i<s.length ; i++){
if(slowerCase[i] === f){
vow += f;
}
}
}
return vow;
}
;)
Here is my simple solution with PHP:
Why there's no
y
? 🤔Python
Python :
def count_vowels(word):
word=word.lower()
data={x:word.count(x) for x in "aeiou"}
return data
Java
Powershell
I do try to keep it as an actual function and give pretty/usable output.
A little late to the party, but this is my JavaScript solution:
My solution is a bit longer because I don't know regex, but it gets the job done.
CodePen
Ruby
In F#