LewisMarz

Sum-Recursion-JS

Sep 17th, 2016
278
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This JS function uses recursion to reproduce the action of a for loop.
  2. var loop = function(i) {
  3.     var limit = 10; // Called limit for clarity.
  4.     if (i < limit) {
  5.         return loop(i + 1);
  6.     }
  7.     return i;
  8. }
  9.  
  10. console.log(loop(1));
Advertisement
Comments
  • Comment was deleted
Add Comment
Please, Sign In to add comment