title: Fibonacci numbers- Ruby Arrays
body: <p>I am trying to solve the problem:</p>
  
  <p>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:</p>
  
  <pre><code>1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
  </code></pre>
  
  <p>By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.</p>
  
  <p>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. </p>
  
  <p>I came up with this code:</p>
  
  <pre><code>def fibonacci(array)
      array = []
      result = array[0] + array[1] 
      i = 2
  
      while result &lt; 4_000_000
          result += array[i]
  
          i += 1
      end
  
      result
  
      array&lt;&lt; result
  
  end
  
  fibonacci([1,2])
  </code></pre>
  
  <p>And I got this error message:</p>
  
  <blockquote>
    <p>(eval):18: undefined method `+' for nil:NilClass (NoMethodError)  from
    (eval):33</p>
  </blockquote>
  
  <p>WHAT AM I DOING WRONG? I feel like I'm doing this all wrong</p>