We had an array [1, 2, 3] this method should return [2, 3, 4]
def increase_by_one(numbers)
#increase the value of each item in the array by one
numbers.map! { |num| num + 1 }
#return the array
numbers
end
What is array?
An array is a data structure that stores a collection of items, each identified by one or more indices. It is used to store a set of related items, usually in the same data type, and access them efficiently. Arrays are most commonly used in computer programming languages to store multiple values in a single variable. This is especially useful when working with large sets of data, as it allows for efficient data manipulation. Arrays can be seen as a form of a list, as they are usually composed of multiple elements that are organized in a certain order.
# The .map! method is being used to iterate through the array, and for each item, increase its value by 1. The ! at the end of the method call is used to signify that the values of the array will be mutated in place, rather than a new array being returned. Finally, the method returns the array with the updated values.
To learn more about array
https://brainly.com/question/28061186
#SPJ4