function rename(str) { try { return eval(str); } catch(e) { return str; } } console.log(rename("(1==1?'66':'77')"));