0

Please expatiate. What does this code output 4? Thanks!

var x = 8; var y = x++ * 5; var z = y % x; alert(z);

2nd Mar 2018, 12:15 PM
BriaŚ”‎
3 Answers
+ 10
var x = 8; var y = x++ * 5; var z = y % x; alert(z); y=8*5=40 after this due to post increment property first value is used then incremented so first the value is used in 8*5 which made y=40 and then value of x is incremented by which x=9 so z=40%9= 4 so output is 4 for more information about increment refer this post https://www.sololearn.com/Discuss/407846/?ref=app
2nd Mar 2018, 12:46 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 12
what is the value of x without x value this can't possible
2nd Mar 2018, 12:35 PM
GAWEN STEASY
GAWEN STEASY - avatar
0
My Bad, Gawen. it's been corrected.
2nd Mar 2018, 12:41 PM
BriaŚ”‎