Page 142 - Computer Software Application TP - Volume 1
P. 142
COMPUTER SOFTWARE APPLICATION - CITS
</head>
<body>
<script>
let age = 20;
// Ternary Operator (conditional operator)
let message = (age >= 18) ? “You are an adult” : “You are a minor”;
console.log(message);
// Output: You are an adult (since age is 20, which is greater than or equal to 18)
// Another example
let result = (age < 0) ? “Invalid age” : “Valid age”;
console.log(result); // Output: Valid age (since age is 20, which is not less than 0)
</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.
TASK 3: Writing Expressions
1 Open the text editor
2 Write the following codes
<html >
<head>
<title> Different types variable </title>
</head>
<body>
<script>
// Arithmetic Expressions
let a = 10;
let b = 5;
127
CITS : IT & ITES - Computer Software Application - Exercise 38 CITS : IT & ITES - Computer Software Application - Exercise 38