IF Statement Worksheet

Question 1

Why is an IF statement known as a control structure?

An IF statement is known as a control structure because it controls the flow of execution in a program. It allows the program to make decisions based on certain conditions.

Question 2

There are other control structures in JavaScript that we'll be learning about soon. Use your google skills to look up the other control structures in JavaScript and list them below.

Switch, for, while, do while, for in, for of, break, and continue.

Question 3

What is a boolean expression?

Boolean expression is an expression in programming that chooses the one of two values, true or false.

Question 4

What is the 'equality operator', and what is it used for? How is it different from the assignment operator?

The equality operator "==" is used to compare values. The assignment operator "=" is used to assign values to variables.

Question 5

Why is it important to properly indent your code when writing IF statements?

Proper indentation improves code readability, prevents errors, and makes maintenance easier.

Question 6

What is a code block in JavaScript?

A code block in JavaScript is a group of statements enclosed in curly braces {}. It is used to define a scope for a set of instructions that are executed together, often in control structures like if, for, while, or functions.

Coding Problems

Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.

Always test your work! Check the console log to make sure there are no errors.