Fibonacci Sequence (JS) - Sum of Even Numbers
Let me break this down:
Why does this show up?
On the console, you will see the result of any expression you execute. If you execute a block of code you will see the last expression you executed in the block. Counter intuitively, in this case it is the result of current = next
because the if statement is not run on your last time through the for loop.
Why does next equal 354224848179262000000?
The hundredth Fibonacci number is 354224848179261915075. JavaScript however loses precision as your numbers get past a certain point and starts assuming that all of the lower part of your number is zeros. See this question for move details: Why does JavaScript think 354224848179262000000 and 354224848179261915075 are equal?.