0

# var x = 8 ,, y = x++ * 5, z = (y % x); alert (z) // z = 0 or 4

What's the out put https://code.sololearn.com/W01eHy160Pct/?ref=app

2 Answers

+ 2

var x = 8
var y = x++ * 5 // 40, after this line x is 9
var z = (y % x) // 40 % 9
alert (z) // 4 because it is the remainder.

+ 1

Output is 4 as
y = x++ * 5 == 8 * 5 == 40
Because x++ will return x and then after will add 1 to it.
z = y % x == 40 % 9 == 4
Because now x is 9!
So z = 4