So i'm kind of lost with this exercise. I found the correct answer by using the hints, but i just don't understand why we must use "Sum = 2".
My code looks like this :
my_array = [1, 2, 3, 4, 5] sum = 2 my_array.each do |n| sum = n*n puts sum end
And i found out it was correct but... why sum = 2 on line 2 ? I get why sum = n*n since i needed to multiple each value with itself but i'm really lost about the line 2. Does someone have an explanation ?
Thanks a lot !