NodeJS - Getting Started with if else statements
by
Jeremy Canfield |
Updated: April 01 2024
| 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 |
|
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