# Sum All Odd Fibonacci Numbers(75024)

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”.

``````
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));

``````

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

your while function is confusing and it is not seem right, you need array with first two elements and then you add their sum in the start of array and do again this action while your number is less then MAX.

next you should check which numbers are odd and sum them up.

1 Like

thanks, i will change my code.

Why make an array? You should only store numbers you need more than once.

Given a positive integer num, return the sum of all odd Fibonacci numbers that are less than or equal to num.

You loop bounds ae not quite right.

2 Likes

the #Guide is locked to avoid vandalism.

2 Likes