Created
November 24, 2016 09:33
-
-
Save Harrisonl/0bdd299409e8ca8e0412572da4d5ac9e to your computer and use it in GitHub Desktop.
This file contains 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
def strip_vowels(string, acc = "") | |
return acc if string.length <= 0 | |
case string[0].downcase | |
when "a" | |
strip_vowels(string[1..-1], acc) | |
when "e" | |
strip_vowels(string[1..-1], acc) | |
when "i" | |
strip_vowels(string[1..-1], acc) | |
when "o" | |
strip_vowels(string[1..-1], acc) | |
when "u" | |
strip_vowels(string[1..-1], acc) | |
else | |
strip_vowels(string[1..-1], acc + string[0]) | |
end | |
end | |
puts strip_vowels("harry") | |
#=> hrry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment