I am trying to convert a string into mathematical expression, so I can calculate the value, but when I use the parseInt
method it returns NAN:
function cal() {
const data = '(2 * 3 + 2) * (2 / 2)';
const info = data.replace(/\s/g, '');
const output = parseInt(info, 10);
console.log(output);
}
cal();