Sum All Odd Fibonacci Numbers

Sum All Odd Fibonacci Numbers
0

#1

Tell us what’s happening:
Created an array of fiboNumbers. Now, i’m iterating through that list testing if divided by 2 they come up with a remainder so I can remove them. For some reason, it is removing odd numbers.

Your code so far

function sumFibs(num) {
  var fibs = [1,1];
  var x = 0;
  for ( i=0; i<num; i++ ){
    fibs.push(fibs[i] + fibs[i+1]);
  }
  
  for ( a=0; a<fibs.length; a++ ){
    if ( fibs[a] % 2 == 0 ){
      fibs = fibs.splice(a,1);
    }
  }
  return fibs[0];
}

sumFibs(4);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36.

Link to the challenge: