IF Statement Worksheet
Question 1
Why is an IF statement known as a control structure?
It is a control stucture because controls "where" your program is going to go.
If this criteria is true, do this. If it is false, do that.
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.
The other control structures in JavaScript are:
- Conditional Structures
- Sequential Structures
- Repitition Stuctures
Question 3
What is a boolean expression?
It is an expression that can be either 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 ==. It compares two values and returns true or false based on the comparison.
The assignment operator is =. It assigns a value to a variable.
Question 5
Why is it important to properly indent your code when writing IF statements?
IF statements can get very complex because they can be nested inside of each other.
Proper indentation makes it easier to read and debug if needed.
Question 6
What is a code block in JavaScript?
It is a piece of code that is enclosed in curly braces and it puts statements in groups.
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.