JS Calculator test case 9 question: formal logic vs immediate execution

For test case 9 it reads:

“The expression 5 - 9 + 5 should produce a result of 1
AssertionError: The expression 5 - 9 + 5 should produce a result of 1”

In my mind, this is immediate execution. If it were formal logic, then the equation would evaluate the 9+5 then evaluate 5-14 which would yield -9. Am I misunderstanding this? Shouldn’t the addition operator take precedence over the subtraction operator?

Addition and subtraction are the same weight. If you think about it, they’re the same operation. Read it this way: “5 plus -9 plus 5.”

They are the same weight, and processleft to right.

1 Like