Term pt.4(conditionals) Flashcards
Control Flow
Control Flow is the order in which statements are executed in a program. The default control flow is for statements to be read and executed in order from left-to-right, top-to-bottom in a program file.
Control Structures
Conditionals such as ( if statements and the like ) alter control flow by only executing blocks of code if certain conditions are met. These structures essentially allow a program to make decisions about which code is executed as the program runs.
Logic Operator ( || )
The logical OR operator ( || ) checks two values and returns a boolean. If one or both values are truthy, it returns ( true ). If both values are falsy, it returns ( false ).
Else Statement
An ( else ) block can be added to an ( if ) block or series of ( if - else if ) blocks. The ( else ) block will be executed only if the ( if ) condition fails.
Else Statement
An ( else ) block can be added to an ( if ) block or series of ( if - else if ) blocks. The ( else ) block will be executed only if the ( if ) condition fails.
Logical Operator ( && )
The Logical AND operator ( && ) checks two values and returns a boolean. If both values are truthy, then it returns ( true ). If one, or both, of the values is falsy, then it returns ( false ).
If Statement
An ( if ) statement accepts an expression with a set of parentheses. If the expression evaluates to a truthy value, then the code within its code body executes vice versa for a falsy value.
If Statement
An ( if ) statement accepts an expression with a set of parentheses. If the expression evaluates to a truthy value, then the code within its code body executes vice versa for a falsy value.
Logical Operator ( ! )
The logical NOT operator ( ! ) can be used to do one of the following:
invert a Boolean value.
invert the truthiness of non-Boolean values.