Solve the Equation

Published by Nomore in

Create a function that takes an equation (e.g. "1+1"), and returns the answer.

Examples

Equation("1+1") ➞ 2

Equation("7*4-2") ➞ 26

Equation("1+1+1+1+1") ➞ 5

Notes

Supported operators are +, -, and *.

Watch a quick demo on how Edabit works.