What will be the output of the following JavaScript code? [code] var a = 10; do { a += 1; console.log(a); } while (a < 5); [/code]

Trường Phan

New member
What will be the output of the following JavaScript code?
Code:
var a = 10;
do {
  	a += 1;
  	console.log(a);
} while (a < 5);
A. 11121314
B. 1112
C. 12345
D. 11
 
Answer: d
Explanation: dowhile loop first executes the statements and after that checks for the condition. Therefore dowhile loop will be executed and after that the condition will become false and the loop will terminate.
 

Tìm kiếm

Back
Top