function sum(n) { return new Function('return '+(new Function('n', 'return 55 + n + 5')(n)))(); }; console.log( sum('+'), sum('-') );