TypeScript Do While Loop Statement

The do...while statement or loop will execute a block of code once, and then it will repeat the loop while a condition is true.

Syntax

do{
   // Code block to be executed.
} 
while (variable<=endvalue);

Note: The <= could be anything that would fit the purpose ex. >, == or whatever.

TypeScript Do While Loop Example 1

Display(temp:number):number
{
	var s : any = "";
	var o = 0;
	do {
		s = s + "\n O is - " + o;
		o++;
	}
	while (temp > o)
	return s;    
}
								
Try it Yourself