0 votes
in JavaScript by
Which one of the following is the correct output for the given JavaScript code?

var a=0;  

var b =0;  

while (a <3)  

{  

    a++;  

    b += a;  

    console.log(b);  

}  

a) 136

b) 123

c) 013

d) 01

1 Answer

0 votes
by

Answer: A

Reason: In the "while" loop statement, the condition is first checked before executing the statements written in the loop's body. Generally, the value of the counter variable incremented at the end of the body of the "while" loop, whereas the statements are executed first.

Related questions

0 votes
asked Mar 21, 2021 in JavaScript by rajeshsharma
0 votes
asked Mar 21, 2021 in JavaScript by rajeshsharma
...