2nd CSS1
2nd CSS1
<html>
<input type="button" value="click me" onclick="disp()">
<script type="text/javascript">
function disp()
{
a=18;
b=15;
if(a>b)
{
alert("a is Greater ");
}
}
</script>
</html>
Output
Client side Scripting Language (22519)
<!DOCTYPE html>
<html>
<head>
<title>Leap Year Checker</title>
</head>
<body>
<h1>Leap Year Checker</h1>
<p>Enter a year to check if it's a leap year:</p>
<input type="text" id="yearInput" placeholder="Enter a year">
<button onclick="checkLeapYear()">Check</button>
<p id="result"></p>
<script>
function checkLeapYear() {
var input = document.getElementById("yearInput").value;
var year = parseInt(input);
if (isNaN(year)) {
document.getElementById("result").textContent = "Please
enter a valid numerical year.";
return;
}
Output
Client side Scripting Language (22519)
If Else
<html>
<input type="button" value="click me" onclick="disp()">
<script type="text/javascript">;
function disp()
{
var i= 7;
if(i<10)
{
alert("7 is less than 10");
}
Else
alert("7 is not less than 10");
}
</script>
</html>
*output
Client side Scripting Language (22519)
3. Nested if Statement
<html>
<input type="button" value="click me" onclick="disp()">
<script type="text/javascript">
function disp()
{
var age = 15;
}
else
{
if (age >= 18 && age <= 60 )
{
alert(" You are Eligible to Work. ");
}
else
{
alert(" You are too old to work as per the Government rules ");
}
}
}
</script>
</html>
Output
Client side Scripting Language (22519)
<!DOCTYPE html>
<html>
<body>
<label for="dayNumber">Enter a day number (1-7):</label>
<input type="number" id="dayNumber">
<button onclick="getDayOfWeek()">Get Day of the Week</button>
<p id="output"></p>
<script>
function getDayOfWeek() {
const dayNumber =
parseInt(document.getElementById("dayNumber").value);
let dayName = "";
switch (dayNumber) {
case 1:
dayName = "Sunday";
break;
case 2:
dayName = "Monday";
break;
case 3:
dayName = "Tuesday";
break;
case 4:
dayName = "Wednesday";
break;
Client side Scripting Language (22519)
Output
Client side Scripting Language (22519)
• LOOPING STATEMENT
• For
<!DOCTYPE html>
<html>
<body>
<h1>Alphabet</h1>
<p id="alphabet"></p>
<script>
var alphabet = "";
for (var i = 97; i <= 122; i++) {
var letter = String.fromCharCode(i);
alphabet += letter;
}
OUTPUT
Client side Scripting Language (22519)
<!DOCTYPE html>
<html>
<head>
<title>Odd Number Finder</title>
</head>
<body>
<h1>Odd Numbers from 1 to 20</h1>
<p>Odd numbers:</p>
<ul id="output"></ul>
Output
Do while loop
<!DOCTYPE html>
<html>
Client side Scripting Language (22519)
Do while loop
<head>
<title>Vowel Finder</title>
</head>
<body>
<label for="inputString">Enter a string:</label>
<input type="text" id="inputString">
<button onclick="findVowels()">Find Vowels</button>
<p id="output"></p>
<script>
function findVowels() {
const inputString = document.getElementById("inputString").value;
const vowels = "aeiouAEIOU";
let foundVowels = "";
let index = 0;
do {
if (vowels.includes(inputString[index])) {
foundVowels += inputString[index] + " ";
}
index++;
} while (index < inputString.length);
Output