18/19 quick q


#1



this is a twist i try to do and try to have a better understanding in the language
why puts my_array inside the methods would have output like this?


with the code belowe, it give out put like this , why?
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
[1, 2, 3, 4, 5]

Replace this line with your code.

my_array = [1, 2, 3, 4, 5]

my_array.each do |n|
n=n*n
puts my_array
end

`


#2

Did you expect something else to happen? Your question is very broad and therefore difficult to answer.

If you expect your program to print square numbers, then I suggest reading your code carefully


#3

my_array = [1, 2, 3, 4, 5]

my_array.each do |n|
n=n*n
puts n
end

you should puts using the n
as the number is supposed to multiply by itself