100+ JavaScript Real-World Problems
(With Solutions)
1. Basics & Strings
Q1. Reverse a string
Q2. Check if a string is a palindrome
Q3. Count vowels in a string
Q4. Find the first non-repeating character
2. Numbers
Q5. Check if a number is prime
Q6. Find factorial of a number
Q7. Find nth Fibonacci number
Q8. Find greatest common divisor (GCD)
3. Arrays
Q9. Find the maximum number in an array
Q10. Remove duplicates from an array
Q11. Flatten a nested array
Q12. Find intersection of two arrays
4. Objects
Q13. Clone an object
Q14. Count character frequency
5. Asynchronous JS
Q15. Fetch data from API
Q16. Delay execution using Promise
6. DOM
Q17. Change text on button click
Q18. Toggle dark mode
7. Real-World Utilities
Q19. Debounce function
Q20. Throttle function
Q21. Shuffle an array
Q22. Generate random hex color
8. Arrays
Q23. Find the second largest number in an array
Q24. Rotate an array by k positions
Q25. Find missing number in a sequence
Q26. Merge two sorted arrays
Q27. Find duplicates in an array
Q28. Chunk an array into smaller arrays
Q29. Find the longest word in an array
Q30. Count occurrences of elements in array
Q31. Remove falsy values from an array
Q32. Find union of two arrays
Q33. Find difference of two arrays
9. Objects
Q34. Convert object to array of key-value pairs
Q35. Convert array of pairs to object
Q36. Deep clone an object
Q37. Merge two objects
Q38. Check if object is empty
Q39. Sort array of objects by key
Q40. Get nested property safely (optional chaining)
10. ES6+ Features
Q41. Default function parameters
Q42. Rest parameter example
Q43. Destructure with defaults
Q44. Template literals
Q45. Use of Set for unique values
11. Asynchronous JavaScript
Q46. Create a function that resolves after 2 seconds
Q47. Async/Await example with error handling
Q48. Run promises in parallel
Q49. Run promises in race
Q50. Retry a function until success
Q51. Sequential promise execution
Q52. Timeout promise
Q53. Polling with setInterval
Q54. Event loop demo (micro vs macro task)
Q55. Implement sleep function
12. DOM Manipulations
Q56. Change background color on button click
Q57. Toggle visibility of an element
Q58. Create and append a new element
Q59. Remove an element from DOM
Q60. Handle form submit without reload
Q61. Image lazy loading
Q62. Add class to element
Q63. Get value of input field
Q64. Smooth scroll to section
Q65. Copy text to clipboard
13. Real-World Utilities
Q66. Capitalize first letter of each word
Q67. Generate UUID
Q68. Check if email is valid
Q69. Convert RGB to Hex
Q70. Convert Hex to RGB
14. OOP in JavaScript
Q71. Create a class with constructor and method
Q72. Inheritance example
Q73. Static method in class
Q74. Private fields
Q75. Getter and Setter
Q76. Polymorphism example
Q77. Prototype method example
Q78. Check instance of a class
Q79. Mixins example
Q80. [Link] inheritance
15. ES6+ Advanced
Q81. Destructure nested objects
Q82. Array destructuring with rest
Q83. Optional chaining
Q84. Nullish coalescing
Q85. Dynamic property keys
Q86. Tagged template literals
Q87. Symbols for unique keys
Q88. Generator function example
16. Performance & Utilities
Q89. Debounce function
Q90. Throttle function
Q91. Memoization
Q92. Lazy loading image
Q93. Throttle scroll event
Q94. Deep clone object
17. Security & Validation
Q95. Validate URL
Q96. Escape HTML to prevent XSS
Q97. Check strong password
Q98. Sanitize input
Q99. Generate random token
Q100. Check if code runs in browser
Q101. Remove duplicates from an array of objects based on a key
Q102. Group array of objects by a key