TypeScript Decision Making

this is way to to run the statements based on condition it satisfy.

there are few way of implementing this.

    1. If block: it will evaluate the boolean expression, if true, it will run the block statements inside it else it will skip.

    Syntax

    example code:

    2. if else : it will evaluate the expression to boolean. expression is true, then run the if block. expression false, run the else block.

    syntax:

    example code:

    3. else if : it will evaluate all the expression until find one true expression and execute respective block statements. if all expression are false, it will execute the else statements.

    syntax:

    example code:

    4. Switch: It will compare variable expression to every case. whichever case matched , it will execute the respective statements.

    Syntax:

    example code:

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Scroll to Top