I've written code to take a string and return the same string back with all the letters changed to the next one and vowels uppercased. However, when I try to run it, the vowels don't seem to uppercase like I expect.
This is my code:
def LetterChanges(str)
str = str.downcase.split (" ")
str.each do |word|
i = 0
while i < word.length
word[i] = word[i].next
word[i].upcase! if word[i] =~ /[aeiou]/
i += 1
end
end
return str.join(" ")
end
LetterChanges("helo world")
Can anyone tell me why my code isn't working?