Introduction
Logical Operators (&&, ||, !)
Logical operators are used to combine or negate boolean expressions. In Wized, you can use &&
(AND), ||
(OR), and !
(NOT) to create more complex conditions and control the flow of your logic precisely.
Example
Using logical operators:
javascript
let isAdmin = false;
let isUser = true;
if (isAdmin || isUser) {
console.log('Access granted');
} else {
console.log('Access denied');
}
Ternary Operator ? :
The ternary operator is a shorthand way of writing an if...else
statement on a single line. In Wized, you can use the ternary operator to assign a value to a variable based on a condition.
Example
Using the ternary operator:
javascript
let age = 18;
let canVote = age >= 18 ? 'You can vote' : 'You cannot vote';
console.log(canVote);