I have been given an assignment to take each number in an array, square it, and return it using the each method (specifically not collect, map, or inject). My code is below,
def square_array(array)
array.each do |number|
new_number = number ** 2
new_array = []
new_array.push (new_number)
return new_array
end
end
but this only returns one number, not each number in an array. Any thoughts on how to do this?