Created
August 22, 2009 22:09
-
-
Save eligrey/173011 to your computer and use it in GitHub Desktop.
JavaScript challenge: Fork this gist and make `mySolution' populate the `results' object with every formal parameter and their values passed to the function. (Yes, it's possible.) A formal parameter is the FOO in (function(FOO){}). To simplify the challe
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 () { | |
function mySolution ({ | |
var, | |
this, | |
function, | |
if, | |
return, | |
true | |
}) { | |
// prohbit reference to arguments and the test object | |
var test = arguments = null, | |
args = ['var', 'this', 'function', 'if', 'return', 'true'], | |
results = {}; | |
// put your solution here | |
return results; | |
}; | |
var test = { | |
"var" : {}, | |
"this" : {}, | |
"function": {}, | |
"if" : {}, | |
"return" : {}, | |
"true" : {} | |
}, | |
results = mySolution(test), | |
pass = true; | |
for (var prop in test) | |
if (test.hasOwnProperty(prop)) | |
if (results[prop] !== test[prop]) | |
pass = false; | |
alert(pass ? "PASS" : "FAIL") | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment