IF Statement Worksheet
Question 1
Why is an IF statement known as a control structure?
Because you can control where the program takes you depending on what you input.
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.
if statement, else if statement, else statement, switch statement, for loop, while loop, do...while loop, for...in loop, for...of loop, break statement, continue statement, try...catch...finally statement
Question 3
What is a boolean expression?
An expression that ends up 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?
An equality operator is a double equal sign (==), it is used for checking if a statement is equal to a value. The assignment operator is a single equal sign (=), it is used to change the value of a statement.
Question 5
Why is it important to properly indent your code when writing IF statements?
So it's easier for you as the programmer to read it. Also so nothing gets messed up by improper indentation.
Question 6
What is a code block in JavaScript?
A code block is a structure of source code which is grouped together, consisting of one or more statements.
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.