(function(){
for (let i = 1; i < 20; i++){
if ((i % 2) === 0) console.log(i + ' ');
}
})();
//you don't have to call it, it'll just show you the result
(function foo() { foo(); })();
// JavaScript Recursive Function:
// A recursive function is a function that calls itself until it doesn't.
function sumArray(array) {
let sum = 0;
for (const item of array) {
sum += Array.isArray(item) ? sumArray(item) : item;
}
return sum;
}
sumArray([1, [4, 6]]); // => 11