Describe what values will the variable s get after executing JavaScript code seg
ID: 3627535 • Letter: D
Question
Describe what values will the variable s get after executing JavaScript code segments Code 1 and Code 2 for each of the (x,y) pairs: (0,0), (0,1), (1,0), (1,1). Please replace the question marks with the corresponding values Code 1 Code 2
CODE 1
s=1;
if (x==1)
s = s+1;
if (y==0)
s = s+2;
CODE 2
s=1;
if (x==1)
s = s+1;
else if (y==0)
s = s+2;
(x,y) value of s in Code 1 value of s in Code 2
x=0, y=0 ? ?
x=0, y=1 ? ?
x=1, y=0 ? ?
x=1, y=1 ? ?
Explanation / Answer
Dear, Values of s after execution of code1 and code2 (x,y) value of s in Code 1 value of s in Code 2x=0, y=0 3 3
x=0, y=1 1 1
x=1, y=0 2 2
x=1, y=1 4 2
Hope this will help you..