Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yeah, passing an object with key-value pairs would be the easiest (and proper) way to give a function "named arguments". I.e., you'd change the function from
function fnname(arg1, arg2)
tofunction fnname({arg1, arg2})
, and change the code that calls it fromfnname(val1, val2)
tofnname({arg1: val1, arg2: val2})
.However, the kata challenge here was to hotfix a pre-existing function that takes ordinary arguments, so it implies that you can't or aren't supposed to modify the function... you're just supposed to wrap it in a new anonymous function that figures out what arguments it expects and provides defaults.
The usual way to do this now seems to be using an object at the end of the arguments to store named arguments, kind of like
kwargs
dict in Python.Not an issue
Not an issue
Added
Yes
You're not handling closures correctly.
No.
I'm getting this error on test 23 it says
ReferenceError: five is not defined at eval at /home/codewarrior/index.js:90:52 at /home/codewarrior/index.js:115:5 at Object.handleError
and the func passed into default arguments is
var timesFive = function () { var five = 5; return function (a) { return five * x; }; }(); function (n) { return five * n; }
which seems wrong.