Awdt Aditya
Awdt Aditya
Output:
Experiment:
PAGE 1
Output:
Experiment:
PAGE 1
let a = 45;
let b = 10;
a = a + b;
b = a - b;
a = a - b;
Output:
Experiment:
PAGE 1
let result;
let op = prompt('Enter operation: ');
switch (op) {
case '+':
console.log(result = n1 + n2);
break;
case '-':
console.log(result = n1 - n2);
break;
case '*':
console.log(result = n1 * n2);
break;
case '/':
console.log(result = n1 / n2);
break;
default:
console.log('Invalid operation');
break;
}
Output:
Experiment:
PAGE 1
let a = 4.6;
let x = 3;
let y = 3;
Output:
Experiment:
PAGE 1
Output:
2. Replacing
Output:
3. Searching digit
Output:
4. Searching pattern
Output:
Experiment:
PAGE 7
Output:
EXPERIMENT - 8
while (a > 0) {
let b = a % 10;
rev = rev * 10 + b;
a = parseInt(a / 10);
}
Output:
With function:
function reverse() {
let a = prompt("Enter a number: ");
let sum = 0;
return sum;
}
const c = reverse();
console.log("Reversed number: " + c);
EXPERIMENT -9
<!DOCTYPE html>
<html>
<head>
<title>Event Handlers Example</title>
</head>
<body>
<h1>Event Handlers Example</h1>
<div id="mouseoverDiv"
style="width: 200px; height: 100px; background-color: lightblue;">
</div> <!-- Mouseover -->
<script>
// Click Event
document.getElementById("clickButton").addEventListener("click", function() {
alert("Button clicked!");
});
// Input Event
document.getElementById("inputField").addEventListener("input", function() {
const inputText = document.getElementById("inputField").value;
console.log("Input changed: " + inputText);
});
// Mouseover Event
document.getElementById("mouseoverDiv").addEventListener("mouseover", function() {
this.style.backgroundColor = "lightgreen";
});
document.getElementById("mouseoverDiv").addEventListener("mouseout", function() {
// Mouseout Event
this.style.backgroundColor = "lightblue";
});
</script>
</body>
</html>
EXPERIMENT -9
Output:
xperiment: 10
#myBtn {
margin-top: 10px;
}
</style>
</head>
<body>
<div id="myText">
This is some text with a green background. And it will change into a blue background.
</div>
<button id="myBtn" onclick="changeColor()">Change Color</button>
<script>
function changeColor() {
var text = document.getElementById("myText");
text.style.backgroundColor = "blue";
}
</script>
</body>
</html>
Output:
E
xperiment: 11
WAP in JavaScript for line breakup pop up message and to display timer.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Timing Sample</h2>
<p>Click on "Try it". Wait 5 seconds, and the page will alert "Hello How are you!!".</p>
<button onclick="setTimeout(myFunction, 5000);">Try it</button>
<script>
function myFunction() {
alert('Hello\n How are you!!');
}
</script>
</body>
</html>
Output:
xperiment: 12-13
const a = Math.random();
console.log(a);
Output:
Output:
EXPERIMENT -14
Create your profile page in html or JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile Page</title>
<style>
body {
background-color: lightblue;
font-family: Arial, sans-serif;
}
.container {
text-align: center;
margin: 0 auto;
width: 50%;
background-color: red;
padding: 20px;
border-radius: 8px;
}
.profile-pic {
width: 100px;
height: 100px;
border-radius: 50%;
margin-bottom: 10px;
}
table, th, td {
border: 1px solid blue;
border-collapse: collapse;
margin: 10px auto;
}
th, td {
padding: 8px;
}
</style>
</head>
<body>
<div class="container">
<img src="https://cdn1.iconfinder.com/data/icons/avatars-1-5/136/60-512.png" alt="Profile Picture"
class="profile-pic">
<h3>Aditya Chugh</h3>
<p>@lol</p>
<button>Follow</button>
<p>Hello, I am Aditya Chugh. I am pursuing a B.Tech in CSE from Amity University and focusing on
Software Development.</p>
<h4>Educational Qualifications:</h4>
<p>School: Vivekanand Sr. Sec. School</p>
<table>
<tr>
<th>Standard</th>
<th>Percentage</th>
</tr>
<tr>
<td>10th</td>
<td>95.8%</td>
</tr>
<tr>
<td>12th</td>
<td>93.4%</td>
</tr>
</table>
<p>University: Amity University, Gurgaon</p>
<h4>Hobbies:</h4>
<ul>
<li>Listening to Music</li>
<li>Reading Books</li>
<li>Gaming</li>
</ul>
<h4>Achievements:</h4>
<ul>
<li>Completed a Web Development Course</li>
<li>Created a Portfolio Website</li>
<li>Scored 93.4% in 12th grade</li>
</ul>
</div>
</body>
</html>
Output:
Experiment: 15
WAP to implement JavaScript array methods.
fruits.push('date');
fruits.unshift('apricot');
console.log(allFruits);
Output: