Choose function according to ternary operators

javascript

Solution

Yes, just replace the square brackets with parentheses. You are creating an array literal, but you want to isolate an expression:

(c==1?a:b)(':p');

This would also work, but there is no reason to use it:

[c==1?a:b][0](':p');

Problem

I've a code: ``` a=function(x){alert(x)} b=function(x){document.write(x)} c=1; [c==1?a:b](':p'); ``` but it's not working. Is possible to do what I want?

Original source