One of the features of the TypeScript language includes a simple, streamlined version of an if then else statement, which uses the question mark (?) symbol to define the if statement, and the colon symbol (:) to define the then and else path. These are called conditional statements. The format of the conditional statement is as follows:
(conditional statement) ? (true value) : (false value);
We start with a conditional statement followed by a ? symbol. We then define the true value and the false value separated by the : symbol. As an example of this, consider the following code:
let trueValue = true; let printValue = trueValue === true ? "true" : "false"; console.log(`printValue is : ${printValue}`);
Here, we have defined ...