TypeScript Break In Loop Control

The break statement in loop controls helps to come out from loop like for loop, for in loop, while loop and do while loop when specific condition meets.

Syntax

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

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

TypeScript Break In Loop Example 1

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