In the previous segments, you learnt about the boolean values in the form of boolean data types and operators. You must be wondering why to use true or false in a programming language. Well, let's find out why.
In the previous video, you learnt about conditionals. In conditionals, some action is performed after the condition is satisfied or not, hence the name. Let’s learn about different kinds of conditionals.
We’ll start with the most literal translation of conditions in JavaScript which is the “if statement.”
You just learnt about if statement. if statements are used to see if a particular condition is evaluating to true or not. If the condition is true then the statement(s) written inside the if block is(are) executed.
Now a good question here would be, what happens in case the if condition is not satisfied? Well, let's find out in the upcoming video with the if-else statement.
So you just saw what is the most direct translation of a condition, i.e. if something is true, do this otherwise do that. Isn’t it interesting that such a basic idea forms the basis of programming?