Greater than and less than operators in JavaScript

To check which value is greater and which is less, the operators greater than >, greater than or equal to >=, less than <, less than or equal to <= are used.

Let's study their work on a practical example. Suppose we have the variable test with some value:

javascriptlet test = 1;

Let's check if the value of this variable is greater than zero or not:

javascriptlet test = 1;

if (test > 0) {
  console.log('+++'); // it will work
} else {
  console.log('---');
}

Now let's change the value of the variable to negative:

javascriptlet test = -1;

if (test > 0) {
  console.log('+++');
} else {
  console.log('---'); // it will work
}

Now let the value of the variable be equal to 0. In this case, we will get into the else block, since our condition says that the variable test must be strictly greater than zero:

javascriptlet test = 0;

if (test > 0) {
  console.log('+++');
} else {
  console.log('---'); // it will work
}

Let's change the condition to greater than or equal to:

javascriptlet test = 0;

if (test >= 0) {
  console.log('+++'); // it will work
} else {
  console.log('---');
}

And now to less than:

javascriptlet test = 0;

if (test < 0) {
  console.log('+++');
} else {
  console.log('---'); // it will work
}

And now to less than or equal to:

javascriptlet test = 0;

if (test <= 0) {
  console.log('+++'); // it will work
} else {
  console.log('---');
}
Задание 1

Check if the variable test is greater than 10.

Задание 2

Check if the variable test is less than 10.

Задание 3

Check if the variable test is greater than or equal to 10.

Задание 4

Check if the variable test is less than or equal to 10.