...

Comparing Numbers

In this lesson, we will learn to create boolean values by comparing numbers. Here's an example:

let score = 85;
let isPassed = score >= 60;
// isPassed will be true because 85 is greater than 60

In this example, we compare the variable score with the number 60. The comparison score >= 60 evaluates to true if the score is 60 or higher, and false otherwise.

Comparison Operators

JavaScript provides several operators to compare numbers, and each comparison results in a boolean value:

OperatorDescriptionExampleResult
>Greater than10 > 5true
<Less than3 < 7true
>=Greater than or equal5 >= 5true
<=Less than or equal4 <= 9true
===Equal to8 === 8true
!==Not equal to8 !== 7true

Complete and run the provided code sample to see the passing score calculator in action!

Loading...

Output (Console)