I am trying to solve the problem:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
In order to solve this question I am first trying make function or method to make a array of Fibonacci numbers. Then I would take it from there.
I came up with this code:
def fibonacci(array)
    array = []
    result = array[0] + array[1] 
    i = 2
    while result < 4_000_000
        result += array[i]
        i += 1
    end
    result
    array<< result
end
fibonacci([1,2])
And I got this error message:
(eval):18: undefined method `+' for nil:NilClass (NoMethodError) from (eval):33
WHAT AM I DOING WRONG? I feel like I'm doing this all wrong
 
     
     
     
    