Skip to content

Instantly share code, notes, and snippets.

@eligrey
Created August 22, 2009 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eligrey/173011 to your computer and use it in GitHub Desktop.
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
(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