The original question was "The function beginsWithVowel should take a single String parameter and return a Bool indicating whether the input string begins with a vowel. If the input string begins with a vowel return true, otherwise return false."
func lowercase(a: String) ->String{
return a.lowercaseString
}
func lowercase(a: String) ->String{
return a.lowercaseString
}
func beginsWithVowel(a: String) ->Bool {
if a.characters[a.startIndex] != ("a") && a.characters[a.startIndex] != ("e") && a.characters[a.startIndex] != ("i") && a.characters[a.startIndex] != ("o") && a.characters[a.startIndex] != ("u") {
print("The word must start with a vowel letter.")
return false
}else {
print("Succes!")
return true
}
}
When the a = ""
beginsWithVowel(lowercase(""))
An error occurred.
What should I add to make the function say reminder sentence instead of an error?
I have tried to add those into my code, but the error still occurred(ps: the func lowercase was added after fails)
a.characters[a.startIndex] != ("")
and
if a.characters.count == 0 {
}