If Expression
This lesson teaches multiple conditional constructs using if statement.
There can be multiple conditional constructs using an if statement.
-
If expression
-
If…else expression
-
If…else if…else expression
-
Nested if expression
-
Shorthand if expression
Let’s discuss each one of them in detail:-
If Expression #
If
expression takes a condition.
If the condition within the if
expression evaluates to be true, then the block of code is executed.
Syntax #
The general syntax is:
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy