JS Else Statement
Syntax
The else statement in JavaScript specifies a block of code to execute if the if condition evaluates to false.
if (condition) { // Code to execute if condition is true} else { // Code to execute if condition is false}Example
let age = 16;
if (age >= 18) { console.log("You are eligible to vote.");} else { console.log("You are not eligible to vote.");}
// Output: You are not eligible to vote.