Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 378 Bytes

8 kyu - Exclamation marks series #11: Replace all vowel to exclamation mark in the sentence.md

File metadata and controls

23 lines (20 loc) · 378 Bytes

Task

Description: Replace all vowel to exclamation mark in the sentence. aeiouAEIOU is vowel.

Examples replace("Hi!") === "H!!" replace("!Hi! Hi!") === "!H!! H!!" replace("aeiou") === "!!!!!" replace("ABCDE") === "!BCD!"

My solution

def replace(s)
  s.tr("aeiouAEIOU", "!")
end

Alternate solution

def replace(s)
  s.gsub(/([aeiou])/i, '!') 
end