Javascript-if-Q&A Flashcards

1
Q

Give 6 examples of comparison operators.

A
  1. Equal to: ==
  2. Strictly equal to: ===
  3. Not equal: !=
  4. Greater than or equal to: >=
  5. Less than equal to: <=
  6. Greater than: >
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the purpose of an if statement?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is else required in order to use an if statement?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the syntax (structure) of an if statement.

A

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
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the three logical operators?

A

Logic operators are used to find the logic between variables in JavaScript. There are three logical operators in JavaScript: || (OR), && (AND), ! (NOT).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What data type do comparison expressions evaluate to?

A

Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you compare two different expressions in the same condition?

A

Logical And &&
Logical Or ||
Logical Not !

How well did you know this?
1
Not at all
2
3
4
5
Perfectly