Write a Ruby program to count the occurrences of a specified character in a given string
def check_string(my_string, chr) return my_string.count(chr) end print check_string("JavaScript", "J") print "\n",check_string("JavaScript", "a") print "\n",check_string("JavaScript", "S")
Output:
1 2 1
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer