javascript if in code example

Example 1: IFFI in js

// This function will be invoked right away we don't have to call it
(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';
  }

Tags:

Cpp Example