[Solved] I have been stuck on this homework: [closed]


Here’s one way to do it – using nested functions:

(function(){
  (function(){
    return arguments[1]<11?arguments.callee(
    arguments[0],arguments[1]+1,arguments[2]+' '+
    (arguments[1]+arguments[0]*10)):console.log(arguments[2]);
  }(arguments[0],1,''));
  return arguments[0]<9?arguments.callee(arguments[0]+1):0;
}(0));

See demo on jsbin.

It will give you extra points for using closures, recursion, immediately invoked function expressions, and not using global variables – thus not polluting the namespace. If you carefully follow the code, fully understand it and be able to explain how it works then you may actually learn much more than doing the homework yourself in the first place.

solved I have been stuck on this homework: [closed]