0% found this document useful (0 votes)
38 views4 pages

Js Test1 (AK)

Uploaded by

Huzef Attar
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)
38 views4 pages

Js Test1 (AK)

Uploaded by

Huzef Attar
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/ 4

Jamia Polytechnic

Akkalkuwa. District: Nandurbar. (MS) – 425 415


Academic Year 2024-25
SESSIONAL EXAM – I
Class: T.Y. Computer Max.Marks:20
Semester: 5rd Date:
Subject: Client Side Scripting Language (22519) Time Duration: 1 Hr
Q.No. Question

1 Attempt any FOUR of following.


What are arithmetic and logical operator used in JS
Ans:- Arithmetic Operators are used to perform mathematical calculations:
a +,-,*,/
Logical Operators are used to perform logical operations:
&&,||,!
How will you define function in JS.
Ans:- In JavaScript, a function is a block of code designed to perform a specific task. It is
b
defined using the function keyword, followed by a name, parentheses (), and curly braces
{} that contain the code to be executed.
Differentiate between prompt() and alert() methods.

Ans:- alert(): Displays a simple pop-up box with a message and an OK button. It's used to
h show information or warnings to the user.

Example: alert("Hello!");
c
prompt(): Displays a pop-up box that asks the user for input, along with a text field to
type in, and OK and Cancel buttons. It's used to get information from the user.

Example: prompt("What is your name?");

Write JS to display first 20 even numbers on the document window.


Ans:-
<script>
document.write("First 20 even numbers: <br>");
for(let i = 1; i <= 20; i++) {
d
if(i % 2 == 0)

document.write(+i+"<br>");
}
</script>

2 Attempt any THREE of following.


a Write a JavaScript function to count the number of vowels in a given string.
Ans:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vowel Counter</title>
</head>
<body>
<h1>Vowel Counter</h1>
<p>Enter a string to count the vowels:</p>

<input type="text" id="inputString" placeholder="Type something...">


<button onclick="countVowels()">Count Vowels</button>

<script>
function countVowels() {
let inputString = document.getElementById("inputString").value;
let vowelCount = 0;
const vowels = "aeiouAEIOU";

for (let i = 0; i < inputString.length; i++) {


if (vowels.includes(inputString[i])) {
vowelCount++;
}
}

document.write("Number of vowels: " + vowelCount);


}
</script>
</body>
</html>
Generate college admission form using html form tag.
Ans:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
b
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>College Admission Form</title>
</head>
<body>
<h1>College Admission Form</h1>
<form>
<!-- Full Name -->
<label>Full Name:</label><br>
<input type="text" placeholder="Enter your full name"><br><br>
<!-- Email -->
<label>Email:</label><br>
<input type="email" placeholder="Enter your email" ><br><br>
<!-- Phone Number -->
<label >Phone Number:</label><br>
<input type="tel" placeholder="Enter your phone number"><br><br>
<!-- Address -->
<label>Address:</label><br>
<textarea id="address" rows="4" cols="50" placeholder="Enter your
address"></textarea>
<br><br>
<!-- Gender -->
<label>Gender:</label><br>
<input type="radio" value="male">
<label for="male">Male</label><br>
<input type="radio" value="female">
<label >Female</label><br>
<input type="radio" value="other">
<label>Other</label><br><br>
<!-- Submit Button -->
<input type="submit" value="Submit">
</form>
</body>
</html>

Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the
result.
Ans:-
<!DOCTYPE html>
<html lang="en">
d <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sort Three Numbers</title>
<script>
function sortNumbers() {
// Get the input values from prompt
var num1 = parseFloat(prompt("Enter the first number:"));
var num2 = parseFloat(prompt("Enter the second number:"));
var num3 = parseFloat(prompt("Enter the third number:"));

// Sorting logic
var sortedNumbers = [num1, num2, num3];
sortedNumbers.sort();

// Display the result


var resultText = "Sorted numbers:" +sortedNumbers;
alert(resultText);
document.write(resultText);
}
sortNumbers();
</script>
</head>
<body>
<h1>Sort Three Numbers using function </h1>
</body>
</html>

You might also like