if (condition) { //block of code to be executed if the condition is true } else { //block of code to be executed if the condition is false }
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>if else</h1>
<input type="button" onclick="chek();" value="check if else">
<script>
function chek()
{
if (30 > 40) //This condition is false so else is execute
{
alert("30 is big");
}
else
{
alert("40 is big");
}
}
</script>
</body>
</html>
If else statement:- Genius student
Reviewed by Network security
on
October 14, 2019
Rating:
No comments: