O'Reilly logo

VMware vRealize Orchestrator Essentials by Daniel Langenhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The if-clause in JavaScript

The if-clause is equivalent to the Decision element that we used in the last chapter. It checks whether a condition has been met.

The JavaScript code for an if statement isn't that difficult. It is made up of a condition and the if-clause itself. The form looks like this:

Statement

Example

if (condition) {
    code block
} else if (condition) {
    code block
} else {
    code block
}
if (varString == "test") {
    varResult=true;
} else {
    varResult=false;
}

In the preceding example, the varString string is tested if it contains the word "test". If it does, the Boolean varResult is set to true. If it is not (the else part), it is set to false. The else if block can be added multiple times.

Conditions and operators

A condition is made ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required