Problem 2: Even Fibonacci Numbers "Your function is not returning the correct result using our tests values."

Problem 2: Even Fibonacci Numbers "Your function is not returning the correct result using our tests values."
0

#1

I couldn’t complet this problem, I succeded on every test except for the: “Your function is not returning the correct result using our tests values.” with the code below:


function fiboEvenSum(number) {
  // You can do it!
  let first = 1, second = 2, next = 0;
  let aux = 2;
  for(let i = 1; i <= number; i++) {
    next = first + second;
    first = second;
    second = next;
    if(next % 2 == 0) aux += next;
  }
  return aux;
}
fiboEvenSum(10);

But then I just changed the i variable initial value from 1 to 2, and it worked just fine. Does anyone have any idea why this happened? How does that test case work?
Thanks!

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/project-euler/problem-2-even-fibonacci-numbers/


#2

well the test instructions say:

the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

Does that answer your question?


#3

Thanks for your answer!

Does that answer your question?

No, at least not completely. In both answers the first 10 items are 1, 2, 3, etc, the only difference is that with i initialized to1 it goes up to 144, instead of 89. Since this doesn´t alter the final result and I don’t make any array to store values, I wanted to know howthe test case manage to know if the function is “returning the correct result using our tests values.”

Sorry If I make any mistake writing


#4