

Sometimes when writing an if statement, we want to combine conditions. Since we get access to the string that's stored in there, this would work so this is a comparison we can make but the overall object or array, that can't be compared. The structure of an if-statement: if (condition) If-statement's structure and the 'condition' != Check for value and type inequality.), and therefore we need to dynamically derive a boolean value and we can do that thankfully with the help of some boolean operators, also known as comparison operators because these are operators built into JavaScript, just like plus, minus, the times operator and so on which don't yield a new number or a new string as a result but which instead return or yield true or false. That is possible but we will not always have a variable that holds true or false, we will need to create that and more often, we'll work with different kinds of data (strings, numbers.


Since a condition in an if-statement was in the end just true or false, we can always pass in a variable that holds true or false into that condition part, so we can always add if and then just check that variable and the value in there. Only booleans could be true or false and that's exactly what we need in a condition because a condition executes code A if it's true or code B if it's false. A condition is in the end just a boolean value. If-statements require conditions, we specify a condition that must be met and a condition is in the end just a boolean value. If-statements are a core construct, not just in JavaScript but actually in any programming language we can learn.

There are some constructs in JavaScript which allow us to write such code. So we have some condition that needs to be met. We might have some program where we either want to run option A (A is a piece of code) or we want to run option B (B is another piece of code). Even if we can build an app without conditional code execution, we can still opt to write cleaner code, shorter code if we can run certain parts of our code conditionally. There are certain, quite a lot of cases, of scenarios which we couldn't really solve or couldn't really handle without the availability of conditional code execution, so without features that help us run code based on certain conditions.
