Write a Ruby program to remove last specified characters from a given string.
def check_string(n, my_string) n.times do my_string.chop! end return my_string end print check_string(1, "JavaScript") print "\n",check_string(2, "JavaScript") print "\n",check_string(3, "JavaScript") print "\n",check_string(4, "JavaScript") print "\n",check_string(5, "JavaScript")
Output:
JavaScrip JavaScri JavaScr JavaSc JavaS
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