# Can't find the Infinite loop

Can't find the Infinite loop
0

#1

I seem to have an infinite loop here somewhere but I’m not seeing it.
The `for` loop seems fine to me (but then I’ve been staring at it for awhile) Any thoughts?

``````function findFibs(num){
let arr = [1,1];
let size = arr.length;
for(let val = 2; val < num; val = arr[size-2] + arr[size-1]){
arr.push(val);
}
return arr;
}

function sumFibs(num) {
return findFibs(num).reduce((sum, curr)=>{
return curr % 2 ? sum += curr: sum;
},0);
}

sumFibs(4);
``````

#2

In your for loop `size` doesn’t change, so `val` is always 2:

``````size = 2
val = arr[size-2] + arr[size-1] = arr[0] + arr[1] = 1 + 1 = 2;
``````

#3

Thanks ::sigh::

redone

``````/*jshint esversion: 6 */

function findFibs(num){
let arr = [1,1];
for(val = 2; val < num; val = arr[arr.length-2] + arr[arr.length-1]){
arr.push(val);
}
return arr;
}

function sumFibs(num) {
return findFibs(num).reduce((sum, curr)=>{
return curr % 2 ? sum += curr: sum;
},0);
}

sumFibs(4);
``````