0% found this document useful (0 votes)
3 views2 pages

JavaScript Practice Programs

The document contains five sample JavaScript programs demonstrating key concepts such as variables and data types, arithmetic operators, comparison operators, looping statements (for loop), and function definition and calling. Each program is presented in an HTML format with embedded JavaScript code that illustrates the respective concept. The author offers to provide additional programs if needed.

Uploaded by

balayya381
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

JavaScript Practice Programs

The document contains five sample JavaScript programs demonstrating key concepts such as variables and data types, arithmetic operators, comparison operators, looping statements (for loop), and function definition and calling. Each program is presented in an HTML format with embedded JavaScript code that illustrates the respective concept. The author offers to provide additional programs if needed.

Uploaded by

balayya381
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

JavaScript Practice Programs

1. Variables and Data Types


<!DOCTYPE html>
<html>
<head>
<title>Variables and Data Types</title>
</head>
<body>
<h2>Variables and Data Types</h2>
<script>
var name = "John";
let age = 25;
const isStudent = true;

document.write("<p>Name: " + name + "</p>");


document.write("<p>Age: " + age + "</p>");
document.write("<p>Is Student: " + isStudent + "</p>");
</script>
</body>
</html>

2. Arithmetic Operators
<!DOCTYPE html>
<html>
<head>
<title>Arithmetic Operators</title>
</head>
<body>
<h2>Arithmetic Operators</h2>
<script>
let a = 10, b = 5;
document.write("<p>Addition: " + (a + b) + "</p>");
document.write("<p>Subtraction: " + (a - b) + "</p>");
document.write("<p>Multiplication: " + (a * b) + "</p>");
document.write("<p>Division: " + (a / b) + "</p>");
document.write("<p>Modulus: " + (a % b) + "</p>");
</script>
</body>
</html>

3. Comparison Operators
<!DOCTYPE html>
<html>
<head>
<title>Comparison Operators</title>
</head>
<body>
<h2>Comparison Operators</h2>
<script>
let x = 5, y = 10;
document.write("<p>Equal to: " + (x == y) + "</p>");
document.write("<p>Not Equal to: " + (x != y) + "</p>");
document.write("<p>Greater than: " + (x > y) + "</p>");
document.write("<p>Less than: " + (x < y) + "</p>");
</script>
</body>
</html>
4. Looping Statements (For Loop)
<!DOCTYPE html>
<html>
<head>
<title>For Loop</title>
</head>
<body>
<h2>For Loop: Numbers from 1 to 5</h2>
<script>
for (let i = 1; i <= 5; i++) {
document.write("<p>" + i + "</p>");
}
</script>
</body>
</html>

5. Function Definition & Calling


<!DOCTYPE html>
<html>
<head>
<title>Functions in JavaScript</title>
</head>
<body>
<h2>Function to Add Two Numbers</h2>
<script>
function addNumbers(a, b) {
return a + b;
}
let result = addNumbers(5, 10);
document.write("<p>Sum: " + result + "</p>");
</script>
</body>
</html>

I have included five sample programs based on your request. If you need more, let me know, and I
will add them accordingly!

You might also like