Skip to content

Sum All Odd Fibonnacci Numbers: Tests fail even though function returns correct answer #8436

@giancarlo88

Description

@giancarlo88

Hello,

I can't pass this algorithm because FCC says I don't pass the test cases. However when I call the same numbers in the test functions myself the correct answer is returned to the console.

Is there something I should fix?

Challenge Sum All Odd Fibonacci Numbers has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Firefox/45.0.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

var prev = 0;
var current = 1;
var next = 0;
var sum = 0;
function sumFibs(num) {
 while (current <= num){
if (current%2 !== 0){
  sum += current
}
next = current + prev;
prev = current
current = next
}


return sum;

}

sumFibs(75025);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions