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?
var a= 0;
var b = 0;
while (a < 3)
{
a++;
b += a;
console.log(b);
}

What will be the output of the following JavaScript code?
var a= 0;
var b = 0;
while (a < 3)
{
a++;
b += a;
console.log(b);
}
a) 135
b) 123
c) 013
d) 01

Answer: a
Explanation: A while loops checks for the condition first before executing the looping statements. A while loop increments the value at the end of the loop whereas for executes the statement at the starting of the loop.

Join The Discussion