Q:

Write a Ruby program to trim specific characters from a string

0

 Write a Ruby program to trim specific characters from a string.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_string(str,chr)
   return str.tr(chr, '')
end
print check_string("JavaScript", 'a')
print "\n",check_string("Python", 'y')
print "\n",check_string("JavaScript", 'JS')

Output:

JvScript
Pthon
avacript

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now