if you wanted to avoid the much-despised eval...
Code:
var str=function(s){
return eval(s.replace(/x/gi,"*"))
}
alert(str("14X10+2X1"))
you could make a dynamic script...
Code:
var str = function (s){
var scr = document.createElement("script");
scr.type = "text/javascript";
scr.text = "ans = " + s.replace(/x/gi,"*") + ";";
document.body.appendChild(scr);
document.body.removeChild(scr);
return ans;
}
alert(str("14X10+2X1"))
although I suspect they amount to much the same thing...