Solve the Equation

Published by corelif 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.