Last active
August 29, 2015 14:27
-
-
Save gyaresu/56ae48da117c224c0e7a to your computer and use it in GitHub Desktop.
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
function mystery (input) { // input is passed in as 3 | |
var secret = 4 // secret doesn't change in all of this. It stays as 4 and is used in the mystery2 function | |
input += 2 // 3 += 2 [input = input + 2] which is 5. | |
function mystery2 (multiplier) { | |
multiplier *= input /* multiplier = 6 * 5 : multiplier gets set when this returned function is | |
finally called as param(6) [after getting temporarily set as the variable `hidden`] */ | |
return secret * multiplier // secret is still just 4 and multiplier is now 30 [6 * 5] from the line above. | |
} | |
return mystery2 // becomes variable `hidden` and then actually called as param(6) | |
} | |
function mystery3 (param) { // hidden is passed in as the param | |
function mystery4 (bonus) { // bonus gets set as `2` from when it's finally called as jumble(2) | |
return param(6) + bonus // param is our returned `mystery2` function | |
// bonus | |
} | |
return mystery4 // becomes jumble() | |
} | |
var hidden = mystery(3) | |
var jumble = mystery3(hidden) | |
var result = jumble(2) | |
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment