If Statement with NOT
if (! condition) {
//code
}
if
is keywordcondition
is a boolean expression!
is JavaScript NOT operator
with the introduction of NOT operator, if condition
is false, then if-block code is run
Examples
1. check if number in a
is not negative
a = 42;
if (!(a < 0)) {
console.log("a is not negative");
}
2. check if string in x
is not empty
x = 'apple';
if (!(x.length == 0)) {
console.log("string is not empty");
}