Back to Web Programming 1

Operators Worksheet

Question 1

What are the comparison operators used for?

To see if a number or string value is equal to or not equal to the one that it's being compared to.

Question 2

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

With && it looks to see if all statements are true, while with || it looks to see if at least one of the statements is true.

Question 3

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

The modulus operator (%).

Question 4

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

The (!=) comparison operator.

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.