IF Statement Worksheet
Question 1
Why is an IF statement known as a control structure?
They control the manner in which your coding runs on their own, hence the term.
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.
We have already learned if/else statements.
There also exist swtich, loop(for, while, & do while), try/catch, break, and continue statements.
Question 3
What is a boolean expression?
A boolean is expression is binary. It can only be one of two values; on or off, true or false, 0 or 1.
Question 4
What is the 'equality operator', and what is it used for? How is it different from the assignment operator?
The equality operator (==) checks if the the two values are the same, whereas the assignment operator (=) changes the former
value to that of the latter.
Question 5
Why is it important to properly indent your code when writing IF statements?
It makes the code easier to read. It can also introduce hidden errors.
Question 6
What is a code block in JavaScript?
Also known as a code branch, this is a portion of a function. In the case of IF statements, it refers to a portion of code
that will happen depending on whether the IF statement itself is true or false.
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.