IF Statement Worksheet
Question 1
Why is an IF statement known as a control structure?
because it dictates when instructions are executed
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.
let,if,else, for,while, try,catch,finally
Question 3
What is a boolean expression?
a boolean expression is an expression that is either false or true
Question 4
What is the 'equality operator', and what is it used for? How is it different from the assignment operator?
its used to see compared valuables. assignment operators are used to assign variables.
Question 5
Why is it important to properly indent your code when writing IF statements?
because if statements can get long and confusing if your code isnt keep neet and readible
Question 6
What is a code block in JavaScript?
anything that goes in the {xxxx}
Question 7
What is a code block in JavaScript?
let input = prompt("Are you a vegetarian (y/n)?");
if(input == "y"){
console.log("I recommend the pasta salad.");
}else if(input == "n"){
console.log("I recommend the prime rib");
}
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.