JavaScript if condition
is used to execute a statement if the condition is true, In our example, if the age is less than 18 then "You are not qualified for Voting" message will be displayed else "You are qualified for Voting" message will be displayed. See the code snippet for JavaScript If condition: