Instead of creating two if
statements, we use an if
/ else
statement to achieve the same result.
let condition = false;
if (condition) {
console.log("1");
} else {
console.log("2");
}
The else
statement of an if
/ else
statement always goes at the end.
let condition = false;
if (condition) {
console.log("1");
} else {
console.log("2");
}