1

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

1 Answer 1

2

You can combine two boolean expression using logical operators like && (AND) and || (OR)

if (process.env.MODULE && process.env.MODULE.includes('reRun)) {
    // do something
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.