if statement with multiple conditions javascript code example

Example 1: multiple conditions for JavaScript .includes() method

const str = "hi, there"

const res = str.includes("hello") || str.includes("hi") || str.includes('howdy');

console.log(res); // true

Example 2: how many else statements can be added in javascript

if (condition a) {
    // code that will execute if condition a is true
} else if (condition b) {
    // code that will execute if condition b is true
} else if (condition c) {
    // code that will execute if condition c is true
} else {
    // code that will execute if all above conditions are false
}

Example 3: function if else javascript

function lessThan100(a, b) {
  let sum;
  if (a + b >= 100) {
    result = false;
  } else {
    result = true;
  }
  return result;
}

Example 4: multiple conditions in javascript

let str = "fuck it I don't care";

let results = []
let results[0] = str.includes("hello") || str.includes("hi") || str.includes("howdy");

console.log(results[0]);

Tags:

Java Example