const isOpen = false;
const isClosed = !isOpen;
console.log(isClosed);isClosed receives true without manually repeating the value.
LESSON 17 OF 50
Use ! to negate a condition.
The logical NOT operator converts its operand to boolean and reverses the result. Negating false produces true.
const isOpen = false;
const isClosed = !isOpen;
console.log(isClosed);isClosed receives true without manually repeating the value.
const isClosed = isOpen;Copying the value preserves false; it does not invert it.
Declare isClosed as the negation of isOpen and print the result.
Run the code to see the result.The ! operator calculates the opposite value, and the console confirms the resulting boolean.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.