Operators Worksheet
Question 1
What are the comparison operators used for?
To compare two variables / numbers.
Question 2
Explain the difference between the logical AND operator (&&) and the logical OR operator (||).
In the instance of an if statement using the AND (&&) operator, if there are two variables that must be true or false together; it will continue only if both are the same. The OR operator will continue if one of the options are true.
Question 3
Which operator would you use to find the remainder from dividing 2 numbers.
The modulus operator (%).
let remainder = 7 % 2;
remainder == 1;
Question 4
Which operator would you use if you wanted to find out if two values were NOT equal?
7 != 5
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.