javascript if in code example
Example 1: IFFI in js
(function () {
console.log("This is an IIFE");
})();
Example 2: javascript if statement
if (5 < 10) {
console.log("5 is less than 10");
} else {
console.log("5 is now bigger than 10")
}
Example 3: javascript if
const number = (Math.random() - 2.5) * 5;
if (number < 0) {
console.log('Number is negative');
}
if (number = 0) {
console.log('Number is zero');
}
if (number > 0) {
console.log('Number is positive');
}
Example 4: if javascript
if (a > 0) {
result = 'positive';
} else {
result = 'NOT positive';
}