What is the output for code A and B?:
*Code A: var x = 10; y = --x + 1; alert(y);
*Code B: var x = 10; y = x-- + 1; alert(y);
a) 11, 10 b) 10, 10
C) 10, 11 d) 11, 11
Answers
Answered by
4
If these are two different conditions then the answer will be:
C)10, 11
C)10, 11
Answered by
0
The output of A and B are option (c)10,11
Explanation:
- before the variable is used to decrease variable value by one before putting the value in the variable.
- after the variable is used to decrease variable value by one after putting the value in the variable.
- here, in A is used before the variable that's why the value of x is decreased by one before it is added to one in
- here, in B is used after the variable that's why the value of x is decreased by one after it is added to one in
- hence, value of y in A is and in B is
Similar questions