How to show a real time calculation in javascript?

A few rare formulas will evaluate correctly with and without operator preference.

That’s why I like to use 6 + 2 * 3 as you can clearly recognise good evaluation from bad.

With correct evaluation you get:
6 + 2 * 3 => 6 + 6 => 12

With sequential evaluation you get:
6 + 2 * 3 => 8 * 3 => 24

One of those answers is correct, and the other is not. Using the correct evaluation order matters.

1 Like