Logical operations in JavaScript
Comparison operators can be used outside
of if constructs. See an example:
javascriptconsole.log(1 == 1); // shows true
console.log(1 == 2); // shows false
You can compare variables:
javascriptlet 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:
javascriptlet a = 1;
let b = 2;
let result = a == b;
console.log(result);
Задание 1
Let the following variables be given:
javascriptlet a = 2 * (3 - 1);
let b = 6 - 2;
Using the operator == find out
if the values of these variables are
equal or not.
Задание 2
Let the following variables be given:
javascriptlet a = 5 * (7 - 4);
let b = 1 + 2 + 7;
Use the operator > to find out
if the variable a is greater
than b.
Задание 3
Let the following variables be given:
javascriptlet a = 2 ** 4;
let b = 4 ** 2;
Using the operator !=, find out
if the values of these variables
are different or not.