Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
int size=5;
int a=5;
int size=4;
for(int j=size;j>=0;j–)
{
console.log(a);
a=a-2;
}

What will be the output of the following JavaScript code?
int size=5;
int a=5;
int size=4;
for(int j=size;j>=0;j–)
{
console.log(a);
a=a-2;
}
a) 5555
b) 5321
c) 531-1
d) 531

Answer: c
Explanation: The value of a will decrease by 2 at every iteration. The for loop will iterate four times till the value of j will decrease to 0.

Join The Discussion