Subscriber only lesson.

Sign up to the Introduction to JavaScript course to view this lesson.

## About this lesson

How to compare two or more variables and test with logic (and, or, not).

## Exercise files

Download this lessonâ€™s related exercise files.

Comparison and Logic Operators.docx199.4 KB Comparison and Logic Operators - Solution.docx

199.6 KB

## Quick reference

### Comparison and Logic Operators

Comparison operators are used to compare, logic operators are used for logic.

### When to use

Anytime you want to compare more than one thing, use comparison operators. Logic operators are used to do basic logic.

### Instructions

The main comparison operators are:

== // equal to

!= // not equal to

> // greater than

>= // greater than or equal to

< // less than

<= // less than or equal to

The main logic operators are

&& // and

|| // or

### Hints & tips

- Use comparison operators to compare things
- remember == is equal to (not =)

Lesson notes are only available for subscribers.