JavaScript Array Scenario-Based Assignments (Without Solution)

1. Student Marks Analysis

Scenario

A teacher has stored the marks of students in an array. Find the highest mark.

Input

[65, 78, 92, 55, 88]

Expected Output

Highest Marks: 92

2. Employee Salary Increment

Scenario

An HR department wants to increase every employee’s salary by 10%.

Input

[25000, 32000, 45000]

Expected Output

[27500, 35200, 49500]

3. Find Failed Students

Scenario

Students scoring less than 35 are considered failed.

Input

[90, 25, 67, 18, 45, 30]

Expected Output

[25, 18, 30]

4. Product Price Filter

Scenario

Display all products costing more than $100.

Input

[50, 120, 90, 300, 150]

Expected Output

[120, 300, 150]

5. Customer Shopping Bill

Scenario

Calculate the total bill amount.

Input

[250, 450, 300, 500]

Expected Output

Total Bill: 1500

6. Remove Duplicate Customer IDs

Scenario

Remove duplicate customer IDs from the array.

Input

[101, 102, 103, 101, 104, 102]

Expected Output

[101, 102, 103, 104]

7. Website Visitor Count

Scenario

Find the average number of daily visitors.

Input

[1200, 1400, 1300, 1500, 1700]

Expected Output

Average Visitors: 1420

8. Online Store Inventory

Scenario

Check whether Product ID 105 exists.

Input

[101, 102, 103, 104]

Expected Output

Product Not Found

9. Company Departments

Scenario

Sort department names alphabetically.

Input

["HR", "Testing", "Development", "Support"]

Expected Output

["Development", "HR", "Support", "Testing"]

10. Reverse Delivery Route

Scenario

Reverse the delivery route.

Input

["Delhi", "Agra", "Jaipur", "Mumbai"]

Expected Output

["Mumbai", "Jaipur", "Agra", "Delhi"]

11. Remove Cancelled Orders

Scenario

Remove order ID 103 from the array.

Input

[101, 102, 103, 104, 105]

Expected Output

[101, 102, 104, 105]

12. Add New Employee

Scenario

Add employee ID 106 to the employee list.

Input

[101, 102, 103]

Expected Output

[101, 102, 103, 106]

13. Highest Monthly Sales

Scenario

Find the maximum sales amount.

Input

[12000, 18000, 25000, 16000]

Expected Output

Highest Sales: 25000

14. Lowest Temperature

Scenario

Find the lowest recorded temperature.

Input

[34, 29, 41, 25, 38]

Expected Output

Lowest Temperature: 25

15. Even Product IDs

Scenario

Display only even product IDs.

Input

[101, 102, 103, 104, 105, 106]

Expected Output

[102, 104, 106]

16. Odd Invoice Numbers

Scenario

Display only odd invoice numbers.

Input

[5001, 5002, 5003, 5004]

Expected Output

[5001, 5003]

17. Positive Bank Transactions

Scenario

Display only deposit transactions.

Input

[-200, 500, -100, 700, 300]

Expected Output

[500, 700, 300]

18. Negative Bank Transactions

Scenario

Display only withdrawal transactions.

Input

[-500, 400, -200, 100]

Expected Output

[-500, -200]

19. Movie Ratings

Scenario

Count how many ratings are greater than or equal to 4.

Input

[5, 3, 4, 2, 5, 4]

Expected Output

Count: 4

20. Bus Seat Numbers

Scenario

Find whether seat number 18 is available.

Input

[10, 12, 14, 16, 18, 20]

Expected Output

Seat Available

21. Daily Expenses

Scenario

Find the total weekly expense.

Input

[500, 650, 400, 700, 300]

Expected Output

Total Expense: 2550

22. Cricket Scores

Scenario

Find the second-highest score.

Input

[55, 72, 89, 91, 68]

Expected Output

Second Highest Score: 89

23. Order Quantity

Scenario

Multiply every order quantity by 2 for a promotional offer.

Input

[5, 10, 15]

Expected Output

[10, 20, 30]

24. Library Books

Scenario

Count the total number of books.

Input

["Java", "Python", "JavaScript", "C++"]

Expected Output

Total Books: 4

25. Hospital Patients

Scenario

Display patient IDs greater than 200.

Input

[150, 180, 205, 210, 175]

Expected Output

[205, 210]

26. Electricity Bills

Scenario

Find all bills greater than $1,000.

Input

[850, 1200, 990, 1400, 600]

Expected Output

[1200, 1400]

27. Flight Ticket Prices

Scenario

Sort ticket prices in ascending order.

Input

[4500, 2200, 6800, 3500]

Expected Output

[2200, 3500, 4500, 6800]

28. Employee Attendance

Scenario

Count the number of days an employee was present (marked as true).

Input

[true, false, true, true, false, true]

Expected Output

Present Days: 4

29. Store Discount

Scenario

Apply a 20% discount to all product prices.

Input

[500, 1000, 1500]

Expected Output

[400, 800, 1200]

30. Olympic Scores

Scenario

Find all scores greater than or equal to 90.

Input

[78, 95, 88, 91, 84, 99]

Expected Output

[95, 91, 99]

Leave a Comment