if else statement in JavaScript

We can use if/else statement to executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed.

<!DOCTYPE html>
<html>
<body>
<p>In this code we will check particular year is a leap year or not</p>
<script type="text/javascript">
var daysInFebruary=29;
if( daysInFebruary==29 ){
document.write("This year is a leapYear");
}
else
{
document.write("This is not a leapyear");
}
</script>
</body>
</html>

Leave a Reply

Your email address will not be published.