I have a string expression like this
10/3*4-7
I'd recommend using a library such as Math.js as this will parse the math expression using a regular expression. This will avoid opening the application up to Cross-site scripting (XSS) attacks.
var answer = math.eval('10/3*4-7');
console.log(answer);
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.6.0/math.min.js"></script>