Checking for equality in JavaScript
To check two values for equality,
use the operator ==. Let's
check for example that the variable
test is equal to 0:
let test = 0;
if (test == 0) {
console.log('+++'); // it will work
} else {
console.log('---');
}
Change the variable value so that the condition is not met:
let test = 1;
if (test == 0) {
console.log('+++');
} else {
console.log('---'); // it will work
}
Check if the variable test
is equal to 10.