You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's build a very basic calculator by programming it. Can you write a function that will evaluate a simple expression string without using your language's eval method?
const expr = "2 + 2";
calculator(expr)
// 4
It should also be able to handle positive and negative symbols +,-, parentheses (), and spaces.
let expr = "3 - 1 + 2";
calculator(expr)
// 4
expr = "(2+(4+2)-1)-(5+8)"
calculator(expr)
// -6
Assume for now that you don't need to handle multiplication or division cases.