Why is last test not passing?

Tell us what’s happening:
I don’t get why my code isn’t passing last test. I used <= as you can see, but it is still broken. Could you figure out why that’s happening?

Your code so far

function sumFibs(num) {
let fibOne = 1;
let fibTwo = 1; 
let fibArr = [];
let finalNum = 0;
while(fibTwo <= num) {
fibOne = fibOne + fibTwo;
fibTwo = fibOne + fibTwo;
for(let i = 0; i < fibArr.length; i++) {
if(fibArr[i] % 2 == 1) {
finalNum = finalNum + fibArr[i];
return (finalNum);


Your browser information:

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

Challenge: Sum All Odd Fibonacci Numbers

Link to the challenge:

Your fibOne in the while loop is smaller or equal to num but it is not pushed to the array.
Below is my solution for your reference:

function sumFibs(num) {
  let fibs = [1, 1];
  while(fibs[fibs.length-1]+fibs[fibs.length-2] <= num) 
  return fibs.filter(x => x%2==1).reduce((x,y)=>x+y);

It is pushed to the array; as you can see here,


Ahh I got it nevermind. I just added this snippet of code.

if(num == fibOne || num == fibTwo) {
  finalNum = finalNum + num;

I need more practice in writing shorter code.

I mean it will happen when (fibTwo > num) but (fibOne <= num).

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

No worries! Couldn’t read that code anyways.