Write a function disemvowel(string), which takes in a string, and
returns that string will all the vowels removed. Treat “y” as a
consonant.

def disemvowel(string)

``````i = 0
while i < string.length
strings = string.split
[string[i] == "a" || string[i] == "e" || string[i] == "i" ||
``````

string[i] == “o” || string[i] == “u”].delete
strings = string.join
end

return strings
end

• I feel that “Strings” variable is unnecessary.
• And “Split” “Join” seems unecessary.

personally I’d just do string.gsub(/[aeiou]/,’’)

Joel P. wrote in post #1178119:

personally I’d just do string.gsub(/[aeiou]/,’’)

For my exercise, I have to do it as long as possible.

However, it’s not working. It won’t run the method.

hi Dhaval B.,

try this

a=“Dhaval B.”

puts a.split(’’).delete_if{|x| [‘a’,‘e’,‘i’,‘o’,‘u’].include?x}.join

output

“Dhvl Bhtt”

Dhaval B. wrote in post #1178134:

For my exercise, I have to do it as long as possible.

def disemvowel(string)
i = 0
strings = string.split
result=""
while i < string.length
car = string[i]
result << car unless car == “a” || car == “e” ||
car == “i” || car == “o” || car == “u”
i+=1
end
result
end

p disemvowel(“you should change of teacher…”)

Regis d’Aubarede wrote in post #1178148:

``````  i+=1
``````

nahh, too short.

x = rand()
i = i + (Math.sin(x)**2 + Math.cos(x)**2).to_i