How is this an infinite loop?!?!

How is this an infinite loop?!?!
0

#1

My code is causing my browser to crash. :confused: can someone tell me why?

function sumFibs(num) {

var allFibs = [1,1];

for (var i = 1; i <= num; i++) {
allFibs.push(allFibs[i] + allFibs[i - 1]);
}

return allFibs;
}

sumFibs(4);


#2

In my Google chrome console your function is working fine. Have you tried another browser as well? Sometimes FCC get stuck may be because of cookies.


#3

You may also see this link if this is the problem https://github.com/freecodecamp/freecodecamp/wiki/FreeCodeCamp-Disable-Code-Autorun


#4

quick note:

you donโ€™t want to push 4 new values, you want to push values that are smaller or equal to 4 in this case


#5

I cleared the cookies, logged into FCC again, and ran the code again on chrome and safari and it caused both to crash. :confused: so it prints out the array on your computer? It works fine?


#6

You can see itโ€™s printing Array at the end.


#7

Have you tried resetting the code in your account?