Operators Worksheet

Question 1

What are the comparison operators used for?

Comparison operators are used to compare two values, for example they are often used in boolean expressions when needing to return a true or false statement.

Question 2

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

Logical operators are used to combine two or more boolean expressions. The two ampersand 'AND' operator '&&' is used to see if two boolean expressions are both true. The two 'pipe' characters '||' representing the 'OR' operator is used to see if one of the two boolean expressions listed is true.

Question 3

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

The 'modulus' operator % is used to find the reaminder in division operations.

Question 4

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

The inequality operator which is represented as '!=' is the operator you use to see if values are NOT equal.

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.