Practical - 1
Aim:
Implement various programs to understand basic JS concepts and Output methods.
Program 1.1
To write a “Hello World” program using JavaScript by linking an external JavaScript file
(HELLO.JS) with an HTML file.
CODE:
FILE 1: HTML file (P 1_1.HTML)
<html>
<head>
<script src="p1.1.js"></script>
</head>
<body>
</body>
</html>
FILE 2: JAVASCRIPT (P1.1.JS)
document.write("Hello World");
OUTPUT:
Program 1.3
To understand how JavaScript is embedded in HTML and to display output using different methods.
CODE:
FILE 1 HTML (P 1_3.HTML)
<html lang="en">
<head>
</head>
<body>
25012011139_TAHIR BHATI
1
, <h2 id="course"></h2>
<script>
document.write("Student Name: STUDENT <br>");
document.getElementById("course").innerHTML="course: IT Workshop";
alert("Welcome to JavaScript Lab");
console.log("JavaScript Output Demonstration");
</script>
</body>
</html>
OUTPUT:
Program 1.4
To study JavaScript variables and data types.
CODE:
FILE 1: HTML(P 1_4.HTML)
<html lang="en">
<head>
</head>
<body>
<script>
let name = "STUDENT";
let age = 19;
const isStudent = true;
document.write("Name: " + name + "<br>");
document.write("Age: " + age + "<br>");
25012011139_TAHIR BHATI
2
Aim:
Implement various programs to understand basic JS concepts and Output methods.
Program 1.1
To write a “Hello World” program using JavaScript by linking an external JavaScript file
(HELLO.JS) with an HTML file.
CODE:
FILE 1: HTML file (P 1_1.HTML)
<html>
<head>
<script src="p1.1.js"></script>
</head>
<body>
</body>
</html>
FILE 2: JAVASCRIPT (P1.1.JS)
document.write("Hello World");
OUTPUT:
Program 1.3
To understand how JavaScript is embedded in HTML and to display output using different methods.
CODE:
FILE 1 HTML (P 1_3.HTML)
<html lang="en">
<head>
</head>
<body>
25012011139_TAHIR BHATI
1
, <h2 id="course"></h2>
<script>
document.write("Student Name: STUDENT <br>");
document.getElementById("course").innerHTML="course: IT Workshop";
alert("Welcome to JavaScript Lab");
console.log("JavaScript Output Demonstration");
</script>
</body>
</html>
OUTPUT:
Program 1.4
To study JavaScript variables and data types.
CODE:
FILE 1: HTML(P 1_4.HTML)
<html lang="en">
<head>
</head>
<body>
<script>
let name = "STUDENT";
let age = 19;
const isStudent = true;
document.write("Name: " + name + "<br>");
document.write("Age: " + age + "<br>");
25012011139_TAHIR BHATI
2