Hi, can someone explain this question as I am having a bit of confusion regarding test case of below question.
i.e sumFibs(4)
should return 5, sumFibs(1000)
should return 1785.
As far as I understand, 1 + 1 + 3 = 5 but why we are using these test cases where we know that we would get a exceeded answer’s?
function sumFibs(num) {
let prev = 0, curr = 1, result = 0;
while(curr <= num){
if(curr % 2 !== 0){
result += curr;
}
curr += prev;
prev = curr - prev;
}
return result;
}
sumFibs(4);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Sum All Odd Fibonacci Numbers
Link to the challenge: