JavaScript - If Else

The if...else statement in JavaScript is used to execute code based on a given condition. It allows you to test a condition and execute different code blocks based on whether the condition is true or false.

Syntax:

if (condition) {

  // code to be executed if condition is true

} else {

  // code to be executed if condition is false

}