0
\$\begingroup\$

Consider an example challenge:

Given a number b and an array a, output the bth element of the array a.

In this case, when requiring input in JavaScript, we need an array and a number as input.

The usual (accepted) function input method are (a,b)=>a[b] or a=>b=>a[b], but can I require to input the array a with extra property b, which is constructed by

a=[1,2,3]; a.b=2;

and the submission is a=>a[a.b] ?

If that's allowed, does it increase the byte-count?

| |
\$\endgroup\$
4
\$\begingroup\$

No

The example challenge requires "an array" and "a number". The "modified array" is not strictly an array.

However, passing a dictionary-like object ({a: [1, 2, 3], b: 2}) is valid.

| |
\$\endgroup\$
  • \$\begingroup\$ Is f({a:[1,2,3],b:2}) explicitly allowed? Is f({'for(i in x)if(i!="b")c=i;x[c][x.b]':[1,2,3],b:2}) explicitly banned as a loophole? \$\endgroup\$ – l4m2 Dec 31 '17 at 6:13
  • \$\begingroup\$ @l4m2 I think that's requiring more input than necessary. \$\endgroup\$ – user202729 Dec 31 '17 at 6:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .