Write a Ruby program to create a new array with the elements in reverse order from a given an array of integers length 3.
def check_array(nums) reversed = nums[2], nums[1], nums[0] return reversed; end print check_array([1, 2, 5]),"\n" print check_array([1, 2, 3]),"\n" print check_array([1, 2, 4])
Output:
[5, 2, 1] [3, 2, 1] [4, 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