Sum All Odd Fibonacci Numbers, not able to pass last test condition

Hi I was able to pass the test conditions set by the challenge except fib(75025), not sure why. Please find below code to the issue. Thank you

function sumFibs(num) {
  
  var num_arr = [1,1];
  var i = 1;
  var result = 0;
  var fib = 0;
  var j = 0;
  
  while ( result < num ) {
    
    result = num_arr[i] + num_arr[i-1];
    num_arr.push(result);
    i++;
  } //with this loop, unsure why the last element is added
    //for instance with num being 4,
    // you get [1,1,2,3,5], why "5"? shouldn't the loop stop and terminate?
  
  
  num_arr.pop(); //pop the last element
  
  while ( j < num_arr.length ) {
    
    if ( num_arr[j] % 2 != 0) {
      
      fib = fib+num_arr[j];
    }
    
    j++;
  }
  return fib;
}
1 Like

Had the same issue. When i finally spotted the issue i face palmed hard!

1 Like