How you define this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How you define this code ?

var x = 5; var y = x++; alert(x++ + y-) How you define this code ? I mean why the y- = 4? Thank you!

20th Nov 2018, 4:48 PM
Rex Hung
2 Answers
0
line 2 : y is set to 5 (and then increments x to 6) line3 : y-- decrements y by 1 and x++ increments x to 7 then alert display the sum 7+4
20th Nov 2018, 6:41 PM
ifl
ifl - avatar
0
Thanks
21st Nov 2018, 2:39 PM
Rex Hung