I have a method that takes in a string and returns a new sentence string where every word longer than 4 characters has all vowels removed. The output should return a modified sentence string to these specs.
def abbreviate_sentence(sent)
arr = []
word = sent.split("")
word.reject do |v|
if word.length > 4
arr << %w(a e i o u).any?.inject(v)
else arr << word
end
end
return arr
end
I get the following error and am trying to include/"inject" the modified elements into a new array in which to join into the desired string described above. If I remove "inject" I get a boolean and not the modified string.
Aucun commentaire:
Enregistrer un commentaire