...

/

Testing Variables and Branching

Testing Variables and Branching

Learn about conditional expressions with the help of interactive examples.

Variable comparison

One of the foundations of any programming language is variable comparison, or variable testing. Depending on the comparison result, we can execute this or another part of a program. Here is an example scenario: if the user’s age is less than 18, we will either ask them for additional information or we will block access for this user. There is a special vocabulary that is used for this functionality. Let’s take a closer look at it:

  • Branching: It is implied that a program may have multiple branches and chunks of code, which can be executed if a certain condition is met.

  • Branch, block, code block: This is usually a few lines of code that can or cannot be executed under certain conditions.

  • Comparison, testing, test, “if statement,” condition: This is the comparison itself, which involves checking if the variable or value equals, does not equal, is greater than, less than, truthy, or falsy, and so on. ...