Operators Worksheet

Question 1

What are the comparison operators used for?

Comparison operators are used when comparing two values. These are commonly used in boolean expressions, which produce a result of "true" or "false".

Question 2

Explain the difference between the logical AND operator (&&) and the logical OR operator (||).

There are two logical operators, which combine two or more boolean expressions - the and operator (&&) and the or operator (||).

The and operator uses two ampersands (&&) to combine two boolean expressions to see if both statements are true.
The or operator uses two pipe characters (||) to combine two boolean expressions to see if one of the two statements are true.

Question 3

Which operator would you use to find the remainder from dividing 2 numbers.

The operator used to find the remainder from dividing 2 numbers would be the modulus, also known as the percentage sign (%).

Question 4

Which operator would you use if you wanted to find out if two values were NOT equal?

To find out if two values were NOT equal, you would use the inequality operator, also known as combining the exclamation point and equals sign (!=).

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.