Page 135 - Computer Software Application TP - Volume 1
P. 135
COMPUTER SOFTWARE APPLICATION - CITS
EXERCISE 38 : Using Variables, Operators and Writing
Expressions
Objectives
At the end of this exercise you shall be able to
• crease variables
• use operators
• use operators
Requirements
Tools/Materials
• Desktop / Laptop with latest configuration
• Text editor
• Web browser
Procedure
TASK 1: Using Variables
I Declaring variables and assigning values
1 Open the text editor
2 Write the following codes
<html >
<head>
<title> Declaring variables and assigning values </title>
</head>
<body>
<script>
// Declaring variables
let x; // Declaration without initialization
let y = 5; // Declaration with initialization
// Assigning values to variables
x = 10;
// Printing variables
console.log(“Value of x:”, x); // Output: 10
console.log(“Value of y:”, y); // Output: 5
// Reassigning variables
x = 20;
y = 8;
console.log(“Updated value of x:”, x); // Output: 20
120