Logical operations in JavaScript

Comparison operators can be used outside of if constructs. See an example:

console.log(1 == 1); // shows true console.log(1 == 2); // shows false

You can compare variables:

let a = 1; let b = 2; console.log(a == b);

You can display the result not immediately to the console, but assign it to some variable:

let a = 1; let b = 2; let result = a == b; console.log(result);

Let the following variables be given:

let a = 2 * (3 - 1); let b = 6 - 2;

Using the operator == find out if the values of these variables are equal or not.

Let the following variables be given:

let a = 5 * (7 - 4); let b = 1 + 2 + 7;

Use the operator > to find out if the variable a is greater than b.

Let the following variables be given:

let a = 2 ** 4; let b = 4 ** 2;

Using the operator !=, find out if the values of these variables are different or not.

enru