javascript-if Flashcards
Give 6 examples of comparison operators.
Some comparison operators: 1. Equal to: == 2. Strictly equal to: === 3. Not equal: != 4. Greater than or equal to: >= 5. Less than equal to: <= 6. Greater than: > Bonus: Less than:
What data type do comparison expressions evaluate to?
Boolean
What is the purpose of an if statement?
The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed. The if/else statement is a part of JavaScript’s “Conditional” Statements, which are used to perform different actions based on different conditions.
Is else required in order to use an if statement?
An if statement looks at any and every thing in the parentheses and if true, executes block of code that follows. If you require code to run only when the statement returns true (and do nothing else if false) then an else statement is not needed.
Describe the syntax (structure) of an if statement.
The if statement specifies a block of code to be executed if a condition is true:
if (condition) { // block of code to be executed if the condition is true }
What are the three logical operators?
Logic operators are used to find the logic between variables in JavaScript. There are three logical operators in JavaScript: || (OR), && (AND), ! (NOT).
How do you compare two different expressions in the same condition?
half of expression, logical operator, half of expression
even: both have to be true
odd: only one have to be true