Operators Worksheet

Question 1

What are the comparison operators used for?

Comparison operators are used to compare two values with each other and to check if they are true or false.

Question 2

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

The AND operator returns "TRUE" if all conditions are met, whereas if any of the conditions are false then the entire expression = FALSE. The OR operator returns a "TRUE" if part or one of the conditions are true. Otherwise, if all conditions are "FALSE" then the entire expression = FALSE.

Question 3

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

You would use the modulus operator (%) to find the remainder when dividing two numbers. When you divide two numbers, the modulus operator gives you the remainder of that division and not the quotient.

Question 4

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

You would use the not-equal operator (!=). This operator compares the values of the two operands.

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.