The decision making in a programming language is similar to decision making in real life. In a programming language, the programmer uses decision making for specifying one or more conditions to be evaluated by the program. The decision making always returns the Boolean result true or false.
There are various types of Decision making in TypeScript:
It is a simple form of decision making. It decides whether the statements will be executed or not, i.e., it checks the condition and returns true if the given condition is satisfied.
a is less than b.
The if statement only returns the result when the condition is true. But if we want to returns something when the condition is false, then we need to use the if-else statement. The if-else statement tests the condition. If the condition is true, it executes if block and if the condition is false, it executes the else block.
The input value is positive Number: 10
Here a user can take decision among multiple options. It starts execution in a top-down approach. When the condition gets true, it executes the associated statement, and the rest of the condition is bypassed. If it does not find any condition true, it returns the final else statement.
Nested if statement
Here, the if statement targets another if statement. The nested if statement means if statement inside the body of another if or else statement.
The largest number is: 25