Suppose now we want to check the value of the variable for false. It can be done like this:
let test = true;
if (test === false) {
console.log('+++');
} else {
console.log('---');
}
You can also write the equivalent code with negation:
let test = true;
if (test !== true) {
console.log('+++');
} else {
console.log('---');
}
The above code can be rewritten in a shortened form as follows:
let test = true;
if (!test) {
console.log('+++');
} else {
console.log('---');
}
Rewrite the following code using the shortened form:
let test = true;
if (test == false) {
console.log('+++');
} else {
console.log('---');
}
Rewrite the following code using the shortened form:
let test = true;
if (test != true) {
console.log('+++');
} else {
console.log('---');
}
Rewrite the following code using the shortened form:
let test = true;
if (test != false) {
console.log('+++');
} else {
console.log('---');
}