Write a piece of JavaScript code that calls alert
with an array containing the first 50 Fibonacci numbers in order. You may only use the following characters: +!()[]
.
As a reference, your code must be functionally equal to the following:
var fib = [], a = 1, b = 1;
for (var _ = 0; _ < 50; _++) {
fib.push(a);
var t = a; a = b; b = t + a;
}
alert(fib);
You may not assume any content on the webpage - your program will be run in the console on about:blank
. Similarly, you may not 'cheat' and store any settings in cookies, settings or other data. Your solution must work on any fresh install of the latest Google Chrome or Firefox on any OS. When in doubt, try to remain as portable as possible.
Smallest source code in bytes wins.