0

I am building a calculator app. Where I store input values in array with operators. e.g

let arr = ['2', '3', '+', '7', '-', '8', '*', '2']

I can't figure out how to handle operator by looping over to get result either 44 or 14 depends on logic.

5
  • 1
    eval(arr.join('')) Commented Jul 10, 2020 at 14:06
  • mathjs.org/docs/expressions/parsing.html Commented Jul 10, 2020 at 14:07
  • "...depends on logic" - The math is quite clear what the correct result should be. Commented Jul 10, 2020 at 14:07
  • @Andreas depends, if you type it on a calculator it would not wait for order of operations. Commented Jul 10, 2020 at 14:11
  • Eval is not recommended to use Commented Jul 10, 2020 at 14:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.