Last active
January 25, 2018 09:00
-
-
Save xiaoyunyang/a852668ff84ace04eacaf0cb11138948 to your computer and use it in GitHub Desktop.
Closure With Recursion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myFun2 = function() { | |
var num = -1 | |
function incrementUntil(max) { | |
if(num >= max) return num | |
num++ | |
incrementUntil(max) | |
} | |
incrementUntil(3) | |
return num | |
} | |
myFun2() //> 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment