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

Practical Questions For JavaScript and Jquery

The document outlines a practical exam for JavaScript and jQuery, consisting of multiple sets of questions worth a total of 100 marks. It includes tasks such as creating functions for various operations, implementing event listeners, and performing data validation. Additionally, it features a section on class creation and salary calculation based on employee details, as well as questions on jQuery functionalities and AJAX calls.

Uploaded by

ojha.subham2004
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)
2 views2 pages

Practical Questions For JavaScript and Jquery

The document outlines a practical exam for JavaScript and jQuery, consisting of multiple sets of questions worth a total of 100 marks. It includes tasks such as creating functions for various operations, implementing event listeners, and performing data validation. Additionally, it features a section on class creation and salary calculation based on employee details, as well as questions on jQuery functionalities and AJAX calls.

Uploaded by

ojha.subham2004
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

Practical Questions for JavaScript and Jquery

(100 Marks) - 3 Hours


_______________________________ SET 1- JavaScipt (3 Marks Each) ___________________________

1. Write a JavaScript function createPerson that takes a name as an argument and returns an
object with a method greet. The greet method should return a greeting message including the
person’s name.

2. Write a JavaScript function compareSums that takes four numbers as input, adds the first
two numbers together, and then compares the sum to the sum of the second two numbers. The
function should return true if the first sum is greater than the second sum, and false otherwise.

3. Write a JavaScript function logicalCheck that takes three Boolean values as input. The
function should return true if at least two of the three values are true, and false otherwise.

[Link] a JavaScript function findFirstEven that takes an array of numbers as input and returns
the first even number found in the array. If there are no even numbers, return null.

5. Write a JavaScript function getDayName that takes a number between 1 and 7 as input and
returns the corresponding day of the week (1 for Monday, 7 for Sunday). If the input is not a
valid number, the function should throw an error.
_______________________________ SET 2- JavaScipt (5 Marks Each) ___________________________

6. Write a JavaScript function highlightElements that selects all <p> elements within a given
container and adds a click event listener to each. When a paragraph is clicked, its background
color should change to yellow. Demonstrate how this function works when passed an element
ID as the container.

7 Write a JavaScript function addListItem that dynamically creates a new list item (<li>) with
specified text and appends it to an unordered list (<ul>) with a given ID. Implement event
delegation so that clicking any list item displays an alert with its text content.

8. Write a JavaScript function OnlyDigits that takes input as an element. if the element value
does not contain only digits then display an appropriate message and return true otherwise
return false.

9. Write a JavaScript function LengthRestrition that takes input as an element. if length of the
element value is not between 6 to 9 chars then display an appropriate message and return true
otherwise return false.

10. Write a JavaScript function CheckData that takes three numbers as input. Print the highest
and lowest number.

11. Write a JavaScript function CheckNumbers that takes input as a number. if the sum of even
digits and sum of odd digits is equal then return true otherwise return false.

12. Write a JavaScript function CheckStrong that takes input as a number. print whether that
number is a strong number or not.

13. Write a JavaScript function findThrees that takes an array of numbers and how many three
are present as an digits in all the element values.
14. Write a JavaScript function findDuplicates that takes an array of numbers and returns an
array of duplicate numbers. Ensure that each duplicate number appears only once in the output
array.

15. Write a JavaScript function capitalizeWords that takes a string and returns a new string with
the first letter of each word capitalized.

16. Declare a class to inherit properties and methods from another class with appropriate
example.
_______________________________ SET 3- JavaScipt (10 Marks Each) ___________________________

17. Create a class named SalaryCalculate in JavaScript. The constructor should accept a
multidimensional array as a parameter, where each inner array represents an employee's
details: EMPNAME, EMPAGE, and BasicSalary. Implement the following methods:

1. calculate: This method should compute the GrandSalary for each employee based on
their age. Use the following rules to determine the HRA:
o If age is between 0 and 30 (inclusive), HRA is 10% of the BasicSalary.
o If age is greater than 30 and up to 50, HRA is 20% of the BasicSalary.
o If age is greater than 50 and up to 100, HRA is 25% of the BasicSalary.

GrandSalary is the sum of BasicSalary and HRA.

2. print: This method should display the salary details of all employees in the following
format:
EMPNAME, EMPAGE, BASICSLARY, HRA, GRANDSALARY.

__________________SET 4- JQuery (5 Marks Each but Question #20 is 10 Marks) ___________________

18. What is the difference between “this” and “$(this)” In jQuery with example?

19. How to use jQuery to make an AJAX call? making a GET request to
‘[Link] If the request is successful, it logs the received data. If
there’s an error, it logs the error details.

20. Do the below form validation for the clientside using jQuery (10 Marks)

You might also like