Page 147 - Computer Software Application TP - Volume 1
P. 147
COMPUTER SOFTWARE APPLICATION - CITS
TASK 3 : Using if-else-if statement
1 Open the text editor
2 Write the following codes
<html >
<head>
<title> if-else-if statement </title>
</head>
<body>
<script>
const age = 17;
const votingAge = 18;
if (age >= votingAge)
{
console.log(“You are eligible to vote.”);
}
else if (age >= 16)
{
console.log(“You can pre-register to vote.”);
}
else
{
console.log(“You are not eligible to vote yet.”);
}
</script>
</body>
</html>
3 Save the program as a .html file
4 Open the html file with a web browser
5 Go to the browsers console tab and verify the output.
132
CITS : IT & ITES - Computer Software Application - Exercise 39