Fibancii challange...can someone please explain why this is happening?

Fibancii challange...can someone please explain why this is happening?
0

#1

its in a spoiler tag because I think its a solution, albeit a bad one.just getting the idea to work first then improving it. I’m not sure if this is a glitch or something I’m not seeing or understanding.


#2

here is the code if you need it.

var fibArr=[0,1];
function sumFibs(num) {
  var newNum=0;
  var total=0;
  while(newNum<=num){
    var i=fibArr.length-1;
    var lastNum=fibArr[i];
    var oldNum=fibArr[i-1];
    fibArr.push(lastNum+oldNum);
    newNum=lastNum+oldNum;
    
  }
  for(var j=0;j<fibArr.length-1;j++){
    if(fibArr[j]%2!=0&& total<num){total+=fibArr[j];
      
    }
  }
  return total;
}

sumFibs(75024);


#3

total<=num i guess!