IF Statement Worksheet

Question 1

Why is an IF statement known as a control structure?

Control structures make the programs able to execute certain sections of code when meeting certain conditions, or not meeting certain conditions. This is exactly what an IF statment does.

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, for in, for of, break, continue, return, throw

Question 3

What is a boolean expression?

Has a value that can only end up being true or false.

Question 4

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

Equality operators are "== or ===" and they are used to compare two values and see if they are equal. Assignment operators dont check for equal, they assign the values to eachother.

Question 5

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

Indenting makes it easier read the code, check for errors in the code, and collaboration with others.

Question 6

What is a code block in JavaScript?

A block of code is the lines of code inside curly braces.

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.