title: JavaScript: calculate the sum of all even numbers in Fibonacci sequence values < 10000
body: <p>I have to complete this exercise, and I am not getting the results I need. </p>
  
  <p>The specifications are: Calculate the sum of all even numbers in a Fibonacci sequence for values under 10,000. The first few numbers summed would be: <strong><em>2, 8, 34, 144, 610</em></strong>.</p>
  
  <p>I have a fiddle that produces this output: <strong><em>10, 44, 188, 798, 3382</em></strong>.</p>
  
  <pre><code>var x = 1;
  var y = 2;
  var sum = 0;
  var limit = 10000;
  var evensum = 2;
  
  while ((x + y) &lt; limit) {
      sum = x + y;
      x = y;
      y = sum;
  
      if (sum % 2 === 0) {
          evensum += sum;
      }
      console.log(evensum);
  }
  </code></pre>
  
  <p>fiddle <a href="https://jsfiddle.net/itortu/dotnojq8/" rel="nofollow">link</a></p>
  
  <p>Could someone please help me figuring out the part I am missing to complete this exercise?</p>
  
  <p>Thank you much.</p>
  
  <p><strong>UPDATE</strong>
  Thank you everyone who posted a solution. They all worked great.</p>