Q:

Write a Ruby program to remove the first and last two characters from a specified string

0

 Write a Ruby program to remove the first and last two characters from a specified string.

All Answers

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

def check_string(str)
   str = str[2...-2]
   return str
end
print check_string("JavaScript")
print "\n",check_string("Python")
print "\n",check_string("Ruby")
print "\n",check_string("PHP")

Output:

vaScri
th

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