+ 1

can anytone tell me why the answer is 1??thanks in advance :)

var a =3; var b = 2; var z =(++b+a--)%5; document.write(z);

14th Sep 2016, 11:16 PM
muhammad aqmal
muhammad aqmal - avatar
2 Answers
+ 4
++b increments the value of b before evaluating it. a-- evaluates the value of a before decrementing it. % gives the remainder of the euclidian division. So z is equals to (3+3)%5, ie 1.
15th Sep 2016, 12:16 AM
Zen
Zen - avatar
0
thank you
14th Sep 2016, 11:47 PM
muhammad aqmal
muhammad aqmal - avatar