Do while loop run at least once because it checked at the end of the iteration.
Syntax:-
do{
// logic
} while(condition)
Example:-
var i=1
do{
console.log(i);
i++;
}while(i<5);
Output:-
1
2
3
4
5
1
2
3
4
5
Javascript do while loop – Interview Questions
Q 1: What is a do...while loop?
Ans: Executes code at least once.
Q 2: Is it exit-controlled?
Ans: Yes.
Q 3: Condition checked when?
Ans: After loop execution.
Q 4: Use case?
Ans: Menu-driven programs.
Q 5: Can it be infinite?
Ans: Yes.
Javascript do while loop – Objective Questions (MCQs)
Q1. The do...while loop executes the code block at least ______.
Q2. The condition in do...while is checked ______.
Q3. Which loop guarantees at least one execution?
Q4. The do...while loop ends with a ______.
Q5. do...while is useful when the loop body must run ______.