How to convert string equation to number in javascript?
Say I have \"100*100\" or \"100x100\" how do I evaluate that and convert to a number?
This will give you the product whether the string is using * or x:
*
x
var str = "100x100"; var tmp_arr = str.split(/[*x]/); var product = tmp_arr[0]*tmp_arr[1]; // 10000