function foo(a, b, c) { return "" === c ? a + b : c - ("" === a ? b : a) }; alert(foo(2,'',7)) alert(foo(2,5,'')) alert(foo('',5,7))