function fn(cond, x, y){ return [function(a,b){return a<b;}, function(a,b){return a>b;}][+cond](x,y); } alert(fn(confirm("Да?"), +prompt("x"), +prompt("y")));