MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 35 lines 576 B view raw
1let x = 1 + 2; 2console.log('1 + 2 =', x); 3 4let y = x * 10; 5console.log('x * 10 =', y); 6 7function add(a, b) { 8 return a + b; 9} 10console.log('add(3, 4) =', add(3, 4)); 11 12// closures 13function counter() { 14 let n = 0; 15 return function () { 16 n = n + 1; 17 return n; 18 }; 19} 20let c = counter(); 21console.log('counter:', c(), c(), c()); 22 23// control flow 24let sum = 0; 25for (let i = 0; i < 10; i = i + 1) { 26 sum = sum + i; 27} 28console.log('sum 0..9 =', sum); 29 30// fibonacci 31function fib(n) { 32 if (n <= 1) return n; 33 return fib(n - 1) + fib(n - 2); 34} 35console.log('fib(10) =', fib(10));