# Sum All Odd Fibonacci Numbers...44

Sum All Odd Fibonacci Numbers...44
0

#1

What’s wrong . everything is working except tjhe last one

``````
function sumFibs(num) {
//b3d ama ngeeb el numbers kolha fee array , mommken n3mlha filter lee el odd numbers wa b3deen reduce
let newa = [];
let frst = 1;
let scnd = 1;
let thrd = 0;
while(thrd<num){
newa.push(scnd);
thrd = frst + scnd;
frst = scnd;
scnd = thrd;
}
newa.unshift(1);
return newa.filter(x=> x%2==1?true:false).reduce((a,b)=>a+b)

}

sumFibs(75025);
``````

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

#2

Dump the array and investigate … Also notice that the previous test is with a number just 1 less, which is a good sign you have an off-by-one error (which you do).

#3

actually i just needed to change that

``````while(thrd<num)
``````

to that

``````while(thrd<=num)
``````

#4

Exactly, as the instructions said.
It’s still an off-by-one error btw.

#5

How?..jkjj

#6

When you’re looping over integer numbers, the difference between greater-than and greater-or-equal is exactly 1.