IF Statement Worksheet

Question 1

Why is an IF statement known as a control structure?

It controls what code is executed when the program is run

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.

else and else if, switch, for, while, do...while

Question 3

What is a boolean expression?

A true or false expression

Question 4

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

This is two equal signs used to compare two values if they're equal, while the assignment operator is used to assign a value to a variable

Question 5

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

It makes it easier to read, helping to visually separate different blocks of code so you can tell if they're a part of the if statement. Also it pisses Niall off if you do it wrong.

Question 6

What is a code block in JavaScript?

A code block is a group of statements that are enclosed in curly braces, and they're used to define the body of functions, loops, and conditional 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.