Bootstrap FreeKB - NodeJS - Getting Started with if else statements
NodeJS - Getting Started with if else statements

Updated:   |  NodeJS articles

An if statement in NodeJS has the following structure.

if (condition) {
  <do something>
} else if (condition) {
  <do something>
} else {
  <do something>
}

 

For example.

if (foo == "Hello") {
  console.log("foo equals Hello");
} else if (foo == "World") {
  console.log("foo equals World");
} else {
  console.log("foo does not equal Hello or World");
}

 

Following are command if statements.

If variable or boolean is defined

tbd

If boolean is True or False tbd
If the foo variable or list is empty

tbd

If foo variable equals the bar variable

tbd

If foo variable does not equal the bar variable

tbd

Greater than

tbd

Less than

tbd

Greater than or equal to

tbd

Less than or equal to

tbd

If file exists

tbd

If file does not exist

tbd

If a variable does or does not contain

see if string contains

If list contains

tbd

if list does not contain tbd
If the foo variable begins with Hello

tbd

tbd tbd

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f56588 in the box below so that we can be sure you are a human.