Advanced freeCodeCamp • top-learn-data-types-and-conditionals

Learn Data Types and Conditionals Lesson F

Lesson Overview

You know that JavaScript has a variety of data types, including strings, numbers and booleans. You can use comparison operators to compare these data types and make decisions based on the results.

You know that JavaScript has a variety of data types, including strings, numbers and booleans. You can use comparison operators to compare these data types and make decisions based on the results.

The following comparison operators are available in JavaScript:

OperatorDescriptionExample
==Equal (value comparison)x == y
!=Not equalx != y
>Greater thanx > y
<Less thanx < y
>=Greater than or equal tox >= y
<=Less than or equal tox <= y

To use a comparison in a variable assignment, you can use the == operator. For example:

let x = 5;
let y = 5;

let result = x == y;

console.log(result); // true