0 votes
in JavaScript by
Which of the following options would be the correct output for the given JavaScript code?

var size=5;  

var x=5;  

var size=4;  

for(var j=size;j>=0;j--)  

{  

    console.log(x);  

    xx=x-2;  

}  

a) 5555

b) 5321

c) 531

d) 531-1-3

1 Answer

0 votes
by

Answer: D

Reason: The value of variable x will decrease 2 times when the loop body executes and the body will execute 4 times until the variable's value of j is 0.

Related questions

0 votes
asked Mar 22, 2021 in JavaScript by Robindeniel
0 votes
asked Mar 24, 2021 in JavaScript by sharadyadav1986
...