Tell us what’s happening:
Hello dear community,
To solve this challenge, I used the loop While and If test for the sum of the odd numbers.
except that for the num: 75024 it doesn’t work, I think the problem in the last number?
Another thing, is it normal that I can’t share my solution with the others in the section “Get a Hint”.
Thank you in advance
Your code so far
function sumFibs(num) {
var newArr = [0,1,1];
var sum =2;
var i=3;
while(sum <= num){
newArr.push(newArr[i-1]+newArr[i-2]);
if(newArr[i]%2 != 0){
sum = sum + newArr[i];
}
i++;
}
console.log(newArr);
return sum;
}
console.log(sumFibs(75024));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0
.
Challenge: Sum All Odd Fibonacci Numbers
Link to the challenge: