Q:

Write a Ruby program to check whether first and the last element are the same of an given array of integers

0

Write a Ruby program to check whether first and the last element are the same of an given array of integers. The array length must be 1 or more.

All Answers

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

def check_string(my_string, my_substr)
    if my_string.include? my_substr
      return "Substring present in the string."
   else
      return "Substring not present in the string."
   end
end
print check_string("JavaScript","Script")
print "\n",check_string("JavaScript","Scriptt")

Output:

Substring present in the string.
Substring not present in the string.

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