Operators Worksheet
Question 1
What are the comparison operators used for?
Comparison operators are used to compare two values.
They return a boolean value: true or false.
Example: 5 > 3 returns true.
Question 2
Explain the difference between the logical AND operator (&&) and the logical OR operator (||).
The logical AND operator (&&) returns true only if both conditions are true.
The logical OR operator (||) returns true if at least one condition is true.
Example:
true && false → false
true || false → true
Example:
true && false → false
true || false → true
Question 3
Which operator would you use to find the remainder from dividing 2 numbers.
The modulus operator (%) is used to find the remainder when dividing two numbers.
Example: 10 % 3 returns 1.
Question 4
Which operator would you use if you wanted to find out if two values were NOT equal?
The != operator checks if two values are NOT equal.
There's also a strict version: !== which checks both value and type.
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.