The "if-else" statement is used to implement conditional logic, allowing you to execute different blocks of code based on whether a given condition is true or false. If the condition in the "if" block is true, the code inside the "if" block is executed. If the condition is false, the code inside the "else" block is executed.
Syntax : if (condition) { // Code to be executed if the condition is true } else {
// Code to be executed if the condition is false }<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tutor Joes</title> </head> <body> <script src="js/script.js"></script> </body> </html>To download raw file Click Here
/* if(condition){ ----- } else{ ----- } */ let age=prompt("Enter Your Age : "); if(age!=null && age>=18) { console.log("You are Eligible for Vote.."); } else { console.log("You are Not Eligible for Vote.."); }To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions