I somewhat understand the reasoning in the comment for why y is equal to 4, but I don't understand why when the variable y is declared with x++ it doesn't increment it and assign 3 instead of just taking the previous declared value?
// In this line: var y = x++ the value of x is assigned to y before x is incremented,
// so y equals 3 on line 2, while x equals 4.
// Therefore on line 3, y now equals 4 instead of 5.
var x = 3;
var y = x++;
y += 1;