Conditionals Flashcards
What are conditional statements?
Conditional statements are used to perform different actions based on different conditions.
What is an “ if “ statement?
An if statement is used to specify a block of JavaScript code to be executed if a condition is true.
What is an “ else “ statement?
An else statement is used to specify a block of code to be executed if the condition is false.
What is an “ else if “ statement?
An else if statement is used to specify a new condition if the first condition is false.
What is a “ switch “ statement?
A switch statement is used to select one of many code blocks to be executed.
What is a “ ternary “ operator?
A conditional operator that assigns a value to a variable based on some condition.
Syntax:
variable name = (condition) ? value1:value2