TypeScript Indefinite Loops
Loops are the sequence of instructions that is continually repeated until a certain condition is reached. It makes the code compact. It is mostly used in the array. Below is the general structure of loop statement:
Loops can be classified into two types:
In Indefinite loops, the number of iterations is not known before beginning to execute the block of statements. There are two indefinite loops:
TypeScript while loop
The TypeScript while loop iterates the elements for the infinite number of times. It executes the instruction each time the specified condition evaluates to true. It should be used if the number of iteration is not known. The syntax of while loop is given below.
The factorial of the given numer is: 24
TypeScript do-while loop
The TypeScript do-while loop iterates the elements for the infinite number of times similar to the while loop except that the code is executed at least once whether the condition is true or false. The syntax of the do while loop is given below.
10 11 12 13 14 15