IF Statement Worksheet
Question 1
Why is an IF statement known as a control structure?
It controls the flow of the program.
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.
According to my google skills other javascript control structures include:
If/else if/else
while
switch
If/else if/else
while
switch
Question 3
What is a boolean expression?
It is an expression that evaluates to 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?
The equality operator uses 2 to 3 equal signs to compare tow values if they are equal.
the assignment operator uses 1 equal sign to give a value to a variable.
the assignment operator uses 1 equal sign to give a value to a variable.
Question 5
Why is it important to properly indent your code when writing IF statements?
To make it easier to read, understand, and show which statement belong to.
Question 6
What is a code block in JavaScript?
It is a group of statements in inside the curly braces.
It will tell which are together.
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");
}
Replace this text with answer/solution to the above problem
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.