Let them offer you a tricky task: make some calling parentheses, like this:
(function() {
// some code
})()(); // multiple calling parentheses
If you think about it, it becomes obvious that in this case the in-place function call should return an anonymous function, like this:
(function() {
return function() {
console.log('!');
};
})()(); // shows '!'
Add the following code so that, when
its running, '!'
will be
displayed:
(function() {
// some code
})()()();
Add the following code so that its launch prints the sum of the numbers passed in the parameters:
(function() {
// some code
})(1)(2);
Add the following code so that its launch prints the sum of the numbers passed in the parameters:
(function() {
// some code
})(1)(2)(3);