Reputation: 2292
I have to check if a variable exists and then if exists, then if its value is this do something. How can I make both in one single if loop
if (process.env.MODULE) {
if (process.env.MODULE.includes("reRun")) {
// Do something
}
}
How can I combine both if loop. So if MODULE value is not defined, it should not return any error. If its defined and its value is reRun, then only it has to do something
Upvotes: 1
Views: 241
Reputation: 670
You can combine two boolean expression using logical operators like && (AND)
and || (OR)
if (process.env.MODULE && process.env.MODULE.includes('reRun)) {
// do something
}
Upvotes: 2