Wit5 1
Wit5 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loop Demonstration</title>
<style>
body { font-family: Arial, sans-serif; }
.output { white-space: pre-wrap; border: 1px solid #ccc; padding: 10px; margin-
top: 10px; }
</style>
</head>
<body>
<h2>Loop Demonstration in JavaScript</h2>
<button onclick="runLoops()">Run Loops</button>
<div class="output" id="output"></div>
<script>
function runLoops() {
let result = "";
document.getElementById("output").innerText = result;
}
</script>
</body>
</html>
OUTPUT:
PROGRAM 6
A HTML program which demonstrate the use of functions in
java script.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Functions Demonstration</title>
<style>
body { font-family: Arial, sans-serif; }
.output { white-space: pre-wrap; border: 1px solid #ccc; padding: 10px; margin-
top: 10px; }
</style>
</head>
<body>
<h2>JavaScript Functions Demonstration</h2>
<button onclick="showMessage()">Call Function</button>
<button onclick="calculateSum(5, 10)">Calculate Sum</button>
<button onclick="displaySquare(4)">Square of a Number</button>
<div class="output" id="output"></div>
<script>
function showMessage() {
document.getElementById("output").innerText = "Hello! This is a simple
function.";
}
function calculateSum(a, b) {
let sum = a + b;
document.getElementById("output").innerText = "Sum of " + a + " and " + b
+ " is: " + sum;
}
function displaySquare(num) {
let square = num * num;
document.getElementById("output").innerText = "Square of " + num + " is: "
+ square;
}
</script>
</body>
</html>
OUTPUT: