An arithmetic expression evaluator turns a math string like "2 + 3 * 4" into the number it represents — 14, not 20 — by honoring operator precedence and parentheses the way a pocket calculator does. You will write arithmeticExpressionEvaluator(expression), which tokenizes the string, parses it, and returns the result as a number. No eval and no new Function: the whole point is to build the parser yourself.
arithmeticExpressionEvaluator(expression: string): number
arithmeticExpressionEvaluator('2 + 3 * 4'); // 14 — '*' binds tighter than '+'
arithmeticExpressionEvaluator('(2 + 3) * 4'); // 20 — parentheses override that
arithmeticExpressionEvaluator('10 - 3 - 2'); // 5 — left to right, not 9
arithmeticExpressionEvaluator('10 / 4'); // 2.5 — real division
arithmeticExpressionEvaluator('3 * -2'); // -6 — unary minus
arithmeticExpressionEvaluator('-(2 + 3)'); // -5 — unary minus on a group
arithmeticExpressionEvaluator('1 +'); // throws — dangling operator
arithmeticExpressionEvaluator('(1 + 2'); // throws — unbalanced parenthesis
3, 3.5). A result can be non-integer: 10 / 4 is 2.5, not 2.* and / bind tighter than + and -, and equal-precedence operators are left-associative, so 8 - 3 - 2 is 3, not 7.(2 + 3) * 4 is 20.- may negate a value or a whole group: -5, 3 * -2, -(2 + 3), and 2 - -3 all work.2+3 and 2 + 3 mean the same thing.Error for unbalanced parentheses, a leading or trailing operator with no operand, an empty string, or an unexpected character, so abc and 2 ** 3 both throw. Division by zero is not malformed: it follows JavaScript and yields Infinity.**), modulo (%), variables, named functions like sqrt, or scientific notation. The four basic operators plus parentheses are the whole surface.