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);
Example 2: how many else statements can be added in javascript
if (condition a) {
} else if (condition b) {
} else if (condition c) {
} else {
}
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]);