var deMo = function (a,b,c) {
var maTh = a -b * c;
return maTh;
};
println(deMo(19,10,2));

```
//19 - 10 * 2 = 18
I thought that subtraction takes precedence over multiplication - no ? The println returned a value of -1 indicating the opposite. What gives?
```

var deMo = function (a,b,c) {
var maTh = a -b * c;
return maTh;
};
println(deMo(19,10,2));

```
//19 - 10 * 2 = 18
I thought that subtraction takes precedence over multiplication - no ? The println returned a value of -1 indicating otherwise.
```

(I don’t think my first posting captured the entirety of my issue)

Multiplication (and division) has precedence over subtraction (and addition). For more on precedence, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

hah - who knew ? - thanks for setting me straight on this

kirupa
August 5, 2020, 2:24am
5
In school we memorized the order of operations as PEMDAS : Parenthesis, exponents, multiplication, division, addition, subtraction

(Addition and subtraction are actually the same. Whichever one is first will win!)

1 Like