0% found this document useful (0 votes)
56 views13 pages

Practical Questions

The document contains 300 practical questions across three programming topics: JavaScript, Node.js, and MongoDB. Each section presents a series of coding challenges aimed at enhancing skills in these technologies. The questions cover a wide range of concepts, from basic functions and queries to more advanced topics like API development and database management.

Uploaded by

abhaysriram12345
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)
56 views13 pages

Practical Questions

The document contains 300 practical questions across three programming topics: JavaScript, Node.js, and MongoDB. Each section presents a series of coding challenges aimed at enhancing skills in these technologies. The questions cover a wide range of concepts, from basic functions and queries to more advanced topics like API development and database management.

Uploaded by

abhaysriram12345
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/ 13

### JavaScript (100 Practical Questions)

1. Write a function to reverse a string.

2. Create a function to check if a string is a palindrome.

3. Implement a function to remove duplicates from an array.

4. Write a function to merge two sorted arrays into one sorted array.

5. Create a function that finds the maximum number in an array.

6. Write a function to calculate the factorial of a number.

7. Implement a function to find the longest word in a sentence.

8. Write a function to flatten a nested array.

9. Create a function that returns the intersection of two arrays.

10. Write a function to count the number of vowels in a string.

11. Create a function to convert an object to an array of key-value pairs.

12. Implement a function to deep clone an object.

13. Write a function to find the unique elements in an array.

14. Create a function to sort an array of objects by a specified key.

15. Write a function to capitalize the first letter of each word in a string.

16. Implement a function that checks if two objects are equal.

17. Write a function to debounce another function.

18. Create a function to throttle another function.

19. Write a function that converts an array of numbers to an object with the numbers as keys
and their squares as values.

20. Implement a function that finds the sum of all elements in a nested array.

21. Write a function to check if an object has a property.

22. Create a function that removes all falsy values from an array.

23. Write a function to count the occurrences of each character in a string.


24. Implement a function that flattens an array up to a specified depth.

25. Write a function to find the missing number in an array of consecutive numbers.

26. Create a function to get the first n elements of an array.

27. Write a function to merge two objects.

28. Implement a function that generates a random hex color code.

29. Write a function to check if a number is prime.

30. Create a function that accepts a string and returns its character count.

31. Write a function to check for balanced parentheses in an expression.

32. Implement a function to find the second largest number in an array.

33. Write a function to find the average of an array of numbers.

34. Create a function that takes an array of strings and returns the longest string.

35. Write a function to rotate an array to the right by a given number of steps.

36. Implement a function to find the highest frequency element in an array.

37. Write a function to merge overlapping intervals.

38. Create a function to get a random element from an array.

39. Write a function to find all the permutations of a string.

40. Implement a function that checks if a string contains only unique characters.

41. Write a function to sort an array of numbers without using built-in sort.

42. Create a function to filter out all non-unique values in an array.

43. Write a function that returns a promise which resolves after a given time.

44. Implement a function to calculate the Fibonacci sequence up to n numbers.

45. Write a function to find the first non-repeated character in a string.

46. Create a function to replace all instances of a substring in a string.

47. Write a function to count the number of occurrences of a specific value in an array.

48. Implement a function to convert a string to title case.


49. Write a function to extract a subset of properties from an object.

50. Create a function to shuffle the elements of an array.

51. Write a function to check if a string is an anagram of another string.

52. Implement a function to find the minimum number in an array.

53. Write a function to generate a random integer between two values.

54. Create a function to convert an array of objects into a single object.

55. Write a function that compares two arrays for equality.

56. Implement a function that sums all numbers in an object recursively.

57. Write a function to replace an item in an array at a specific index.

58. Create a function to generate a random string of specified length.

59. Write a function to get the keys of an object as an array.

60. Implement a function that returns the last element of an array.

61. Write a function to check if a number is a power of two.

62. Create a function to generate a frequency object from an array.

63. Write a function to deep merge two objects.

64. Implement a function to find the common elements in two arrays.

65. Write a function to capitalize each word in an array of strings.

66. Create a function to find all pairs of integers that sum to a target value.

67. Write a function to remove a specific item from an array by value.

68. Implement a function to find all elements that appear more than once in an array.

69. Write a function to generate all subsets of an array.

70. Create a function to return the longest common prefix from an array of strings.

71. Write a function to calculate the product of all elements in an array.

72. Implement a function to group an array of objects by a specified property.

73. Write a function to compare two objects and return the differences.
74. Create a function to check if a string contains a valid number.

75. Write a function that finds the index of a specific value in an array.

76. Implement a function that replaces all spaces in a string with a specified character.

77. Write a function to get the maximum profit from an array of stock prices.

78. Create a function to find the longest substring without repeating characters.

79. Write a function to extract all unique values from an array of objects.

80. Implement a function that returns the intersection of two arrays.

81. Write a function to format a date string to a specified format.

82. Create a function to check if a string ends with a specific substring.

83. Write a function to get the current timestamp in seconds.

84. Implement a function that converts a string to lowercase.

85. Write a function to extract all email addresses from a string.

86. Create a function that finds the minimum value in an object based on its properties.

87. Write a function to sum up all numeric values in an object.

88. Implement a function to convert a time string (HH:MM) to total minutes.

89. Write a function to count the number of words in a string.

90. Create a function to find the difference between two arrays.

91. Write a function to check if a number is even or odd.

92. Implement a function to split a string into an array based on a delimiter.

93. Write a function to remove a specific property from an object.

94. Create a function that returns the first n Fibonacci numbers.

95. Write a function to calculate the GCD of two numbers.

96. Implement a function to format currency in a specified locale.

97. Write a function to find the longest sequence of repeated characters in a string.

98. Create a function that checks if an array is sorted.


99. Write a function to get the value of a specific nested property in an object.

100. Implement a function to deep freeze an object.

---

### Node.js (100 Practical Questions)

1. Create a simple HTTP server that responds with "Hello, World!".

2. Set up routing in Express for a RESTful API.

3. Write middleware to log incoming requests to the console.

4. Implement error handling middleware in an Express application.

5. Connect to a MongoDB database using Mongoose.

6. Create a POST endpoint to add a new user to the database.

7. Implement a GET endpoint to retrieve all users from the database.

8. Write a PUT endpoint to update user details.

9. Create a DELETE endpoint to remove a user by ID.

10. Implement a function to hash passwords before storing them in the database.

11. Set up CORS in an Express application.

12. Write a function to validate user input using Joi or express-validator.

13. Create a simple login endpoint that verifies user credentials.

14. Implement JWT-based authentication in an Express application.

15. Create a file upload endpoint using Multer.

16. Write a function to send email notifications using Nodemailer.

17. Create an endpoint to retrieve a single user by ID.

18. Write a function to paginate results in a GET request.


19. Implement a search functionality for users by name.

20. Create a rate-limiting middleware for your API.

21. Write a function to generate API documentation using Swagger.

22. Create a WebSocket server to handle real-time communication.

23. Implement a simple chat application using Socket.IO.

24. Write a function to stream video files in Node.js.

25. Create a simple task scheduler using node-cron.

26. Write a function to parse incoming JSON requests.

27. Implement session management using express-session.

28. Write a function to fetch and display weather data from an external API.

29. Create a RESTful API for a book collection.

30. Implement a file download endpoint.

31. Write a function to clean up old log files in a directory.

32. Create a function to read and parse a CSV file.

33. Write a function to create and serve static files in Express.

34. Implement a function to backup database entries to a JSON file.

35. Create a cron job to perform daily database maintenance.

36. Write a function to connect to an external API and cache responses.

37. Create an API endpoint to filter users by age.

38. Implement a function to validate JWT tokens.

39. Write a function to handle unhandled promise rejections.

40. Create an Express route that handles both GET and POST requests

41. Write a function to compress responses using gzip.

42. Implement a simple user profile upload feature.

43. Create an API to manage user roles and permissions.


44. Write a function to log request durations.

45. Implement a function to serve HTML files from a directory.

46. Create an API to manage to-do tasks.

47. Write a function to parse query parameters in a request.

48. Implement a caching layer using Redis.

49. Create an endpoint to reset a user’s password.

50. Write a function to handle different content types in a response.

51. Implement a function to prevent SQL injection in database queries.

52. Create a middleware to restrict access to certain routes.

53. Write a function to get the current user's IP address.

54. Implement a function to set response headers.

55. Create an API to manage blog posts.

56. Write a function to handle file read and write operations asynchronously.

57. Implement a health check endpoint for your API.

58. Create a function to generate unique identifiers for users.

59. Write a function to compare the current version of your API.

60. Implement a function to log errors to a file.

61. Create a function to check the status of external APIs.

62. Write a function to serve different HTML pages based on routes.

63. Implement a function to manage user sessions with cookies.

64. Create an API for managing products in an online store.

65. Write a function to format dates in responses.

66. Implement a function to sanitize user input to prevent XSS attacks.

67. Create a middleware to restrict API usage based on user roles.

68. Write a function to handle payment processing with an external API.


69. Implement a function to display server statistics.

70. Create an API to manage customer support tickets.

71. Write a function to retrieve the current server time.

72. Implement a function to send SMS notifications using Twilio.

73. Create a simple blog application with CRUD operations.

74. Write a function to parse and display JSON data from an external source.

75. Implement a function to handle user logout and session destruction.

76. Create an API endpoint to get user activity logs.

77. Write a function to implement content negotiation in an API.

78. Implement a function to manage product inventory.

79. Create an endpoint to download reports in PDF format.

80. Write a function to search products by keyword in the database.

81. Implement a function to send push notifications to users.

82. Create an API to manage user subscriptions.

83. Write a function to handle file uploads with file type validation.

84. Implement a function to log all API requests and responses.

85. Create a middleware to compress responses for specific routes.

86. Write a function to extract data from an external API and store it.

87. Implement a function to manage user preferences.

88. Create an API to manage event registrations.

89. Write a function to display user profiles with activity summaries.

90. Implement a function to handle 404 errors.

91. Create an API to manage forum posts and comments.

92. Write a function to send reminders via email.

93. Implement a function to create scheduled tasks in the database.


94. Create an endpoint to retrieve user notifications.

95. Write a function to aggregate user statistics.

96. Implement a function to manage access tokens for users.

97. Create an API to handle feedback submissions.

98. Write a function to enable user two-factor authentication.

99. Implement a function to log out users after a period of inactivity.

100. Create a middleware to enforce SSL connections.

---

### MongoDB (100 Practical Questions)

1. Write a query to insert a new document into a collection.

2. Create a query to find all documents in a collection.

3. Write a query to find a document by a specific field value.

4. Implement a query to update a document's field value.

5. Write a query to delete a document by its ID.

6. Create an aggregation pipeline to group documents by a field.

7. Write a query to sort documents in a collection.

8. Implement a query to count the number of documents in a collection.

9. Write a query to find documents that match multiple criteria.

10. Create a query to perform a text search on a collection.

11. Write a query to update multiple documents in a collection.

12. Implement a query to find documents with a specific nested field value.

13. Write a query to project specific fields in the result.


14. Create an index on a specific field in a collection.

15. Write a query to find documents within a range of values.

16. Implement a query to find documents based on an array field.

17. Write a query to perform a left join between two collections using `$lookup`.

18. Create a query to find distinct values of a specific field.

19. Write a query to update a document and return the updated document.

20. Implement a query to delete multiple documents based on a condition.

21. Write a query to find documents created within the last 7 days.

22. Create a query to group and sum values from documents.

23. Write a query to find documents with an array that contains a specific value.

24. Implement a query to use `$unwind` on an array field.

25. Write a query to find documents where a field exists.

26. Create a query to aggregate data and get the average value of a field.

27. Write a query to insert multiple documents at once.

28. Implement a query to find documents that do not have a specific field.

29. Write a query to rename a field in all documents.

30. Create a query to add a new field to all documents in a collection.

31. Write a query to find documents that match a specific regex pattern.

32. Implement a query to perform a case-insensitive search.

33. Write a query to calculate the total number of items in an array field.

34. Create a query to perform a full-text search on a collection.

35. Write a query to find documents where a field is greater than or less than a specific value.

36. Implement a query to use `$facet` to perform multiple aggregations at once.

37. Write a query to create a compound index on multiple fields.

38. Create a query to project fields based on a condition.


39. Write a query to update a field in documents that match a specific condition.

40. Implement a query to find documents with an exact match on a field.

41. Write a query to delete all documents that match a specific condition.

42. Create a query to find the maximum value of a field in a collection.

43. Write a query to perform an update operation using `$set`.

44. Implement a query to find documents based on a date range.

45. Write a query to retrieve documents sorted by multiple fields.

46. Create a query to update nested fields in documents.

47. Write a query to retrieve documents that contain a specific string.

48. Implement a query to use `$group` for counting distinct values.

49. Write a query to find documents that are older than a certain date.

50. Create a query to insert a document with a unique index constraint.

51. Write a query to use `$match` within an aggregation pipeline.

52. Implement a query to retrieve documents with pagination.

53. Write a query to find the average of a numerical field across documents.

54. Create a query to merge documents from two collections.

55. Write a query to find documents that have arrays of specific lengths.

56. Implement a query to use `$replaceRoot` in an aggregation pipeline.

57. Write a query to find the last n documents inserted in a collection.

58. Create a query to update documents with array fields.

59. Write a query to find documents that contain an embedded document.

60. Implement a query to use `$addFields` to add new fields to documents.

61. Write a query to find the first document that matches a condition.

62. Create a query to perform a subquery within a main query.

63. Write a query to use `$project` to reshape documents.


64. Implement a query to find documents based on multiple criteria using `$and`.

65. Write a query to delete a specific document by its unique field.

66. Create a query to find documents where the field value is null.

67. Write a query to perform a conditional update using `$cond`.

68. Implement a query to find documents with a specific field value within a specific set.

69. Write a query to use `$sort` in an aggregation pipeline.

70. Create a query to find documents with a specific combination of fields.

71. Write a query to check for duplicate entries based on specific fields.

72. Implement a query to use `$merge` to insert or update documents.

73. Write a query to get the total count of documents in a collection.

74. Create a query to find documents based on a specific field's substring.

75. Write a query to count the number of documents grouped by a field.

76. Implement a query to use `$project` to exclude specific fields.

77. Write a query to retrieve documents using aggregation with `$lookup`.

78. Create a query to find documents where a field matches multiple values.

79. Write a query to calculate the median of a field across documents.

80. Implement a query to find the total revenue based on sales data.

81. Write a query to use `$match` to filter documents in an aggregation.

82. Create a query to retrieve documents sorted in descending order.

83. Write a query to find documents with specific nested array elements.

84. Implement a query to calculate the sum of a field across grouped documents.

85. Write a query to find documents with specific field names in an array.

86. Create a query to update multiple fields in a single document.

87. Write a query to find documents based on a specific user ID.

88. Implement a query to return only unique field values.


89. Write a query to perform a full text search with weighting.

90. Create a query to update an array field by adding a new element.

91. Write a query to find documents with the latest date in a collection.

92. Implement a query to aggregate data using `$bucket`.

93. Write a query to create a unique index on a field.

94. Create a query to find documents with a specific status.

95. Write a query to count distinct values of a field using aggregation.

96. Implement a query to update documents based on an external condition.

97. Write a query to use `$sample` to get random documents.

98. Create a query to paginate results based on skip and limit.

99. Write a query to convert a field value to another type.

100. Implement a query to find documents with complex filtering conditions.

You might also like