There is an array of elements. How to make mathematical operations?

There is an array of type elems = ["12","+","4", "*", "2", "/", "34"].
How to bring to mind res = 12 + 4 * 2 / 34 ?
June 8th 19 at 16:50
1 answer
June 8th 19 at 16:52
Solution
The same thing, but without eval.

numToFn function(fn) {
 return new Function('return' + fn)();
}
elems = ["12","+","4", "*", "2", "/", "34"];

console.log( elems.join(") + ' = ' + numToFn(elems.join(")) );

Find more questions by tags JavaScript