Sum All Odd Fibonacci Numbers Priyatam

Tell us what’s happening:
sumFibs(75025) should return 135721. why it does not fullfill. Is anything wrong in my code?

Your code so far

function sumFibs(num) {
  var n = [1, 1];
  var k;
  for (var i = 3; i <= num; ++i){
    k = n[i-2] + n[i-3];
    if (k < num){
  n = n.filter(function(b){
    if (b % 2 !== 0){
      return b;
  return n.reduce(function(a, c){
    return a + c;


Your browser information:

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

Link to the challenge:

You should add together all of the Fibonacci numbers less than or equal to num.

1 Like

Your condition for pushing your next Fibonacci number If (k<num) { is being evaluated as a false, for the test that doesn’t pass.

Perhaps, reconsider the condition slightly? I think a slight refactor would bring it from red to green. :slight_smile:

My suggested solution:

Change the if - else in your for loop as below:

        //...for loop
    if ( k <= num) {  //your condition was triggered because the num was equal in your last test.
    } else {
    // of code