Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fun(x, n) {
- if (n == 1) {
- return x;
- } else {
- var add = (function() {
- var counter = n;
- return function() { counter += 1; return counter }
- })();
- add();
- add();
- return add();
- }
- }
- alert(fun(2, 6));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement