TypeScript While Loop Statement

The while statement or loop will execute a block of code while a given condition is true.

Syntax

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

TypeScript While Loop Example 1

Try it Yourself

The while loop sets x equal to 0. As long as x is less than temp, the loop will continue to run. x will increase by 1 each time the loop runs.