This repository contains a collection of JavaScript coding problems ranging from basic to advanced topics. Each problem is categorized by topic to help you practice and improve your JavaScript skills.
-
Hello World
Print "Hello, World!" to the console. -
Variables and Constants
Declare variables of different types (string, number, boolean).
Declare and initialize constants. -
Operators
Perform basic arithmetic operations (addition, subtraction, multiplication, division).
Use comparison operators (>, <, ===, !==). -
Control Structures
Implement conditional statements (if-else, switch-case).
Use loops (for, while) to iterate over arrays and objects. -
Functions
Define a function that takes parameters and returns a value.
Write functions with default parameters and rest parameters. -
Arrays
Create arrays and perform operations like push, pop, shift, unshift.
Iterate through arrays using for loops and forEach. -
Strings
Concatenate two strings.
Find the length of a string.
Convert a string to uppercase or lowercase. -
Objects
Create objects with properties and methods.
Access object properties using dot notation and bracket notation. -
Scope and Hoisting
Understand variable scope inside and outside functions.
Recognize and explain function and variable hoisting. -
Type Conversion
Convert between different data types (string to number, number to string). -
Error Handling
Use try-catch blocks to handle exceptions.
Throw custom errors with throw statements. -
DOM Manipulation
Select and manipulate DOM elements using vanilla JavaScript.
Handle events (click, mouseover, keypress) on DOM elements. -
Asynchronous JavaScript
Use callbacks to handle asynchronous operations.
Fetch data from an API using fetch() and handle responses. -
LocalStorage
Store and retrieve data from the browser's localStorage.
Use localStorage to persist user settings or data. -
Regular Expressions
Create regular expressions to match patterns in strings.
Use RegExp methods like test() and exec(). -
Math Operations
Perform mathematical operations (exponents, square roots). -
Date and Time
Manipulate dates (formatting, adding days, calculating differences). -
Functional Programming
Use higher-order functions (map, filter, reduce) to process data. -
ES5 vs ES6 Syntax
Convert ES5 code to ES6 syntax and vice versa. -
Bitwise Operations
Perform bitwise operations (AND, OR, XOR, shift).
-
Array Operations
Create an array and perform operations like push, pop, shift, unshift, etc. -
Array Iteration
Write a function to iterate through an array and perform an operation on each element. -
Array Methods
Use array methods such as map(), filter(), reduce(), and forEach(). -
Sorting
Implement sorting algorithms for arrays (bubble sort, merge sort, quick sort). -
Searching
Implement searching algorithms for arrays (binary search, linear search). -
Multi-dimensional Arrays
Manipulate and traverse multi-dimensional arrays. -
Array Slice and Splice
Use slice() and splice() to manipulate arrays. -
Flatten an Array
Flatten nested arrays into a single array. -
Array Comparison
Compare two arrays and find common elements. -
Rotate an Array
Rotate elements of an array to the left or right. -
Shuffle an Array
Shuffle elements randomly in an array. -
Find Maximum and Minimum
Find the maximum and minimum values in an array. -
Remove Duplicates
Remove duplicate elements from an array. -
Array Concatenation
Concatenate multiple arrays into one. -
Sparse Arrays
Handle sparse arrays and their implications. -
Palindrome Array
Check if an array is a palindrome. -
Chunk an Array
Split an array into chunks of a specified size. -
Intersecting Arrays
Find common elements between two arrays. -
Array Reverse
Reverse the elements of an array in place. -
Insert Element at Index
Insert an element at a specific index in an array.
-
String Manipulation
Concatenate two strings.
Find the length of a string.
Convert a string to uppercase or lowercase. -
Substring Operations
Extract a substring from a string.
Replace substrings within a string. -
Regular Expressions
Use regular expressions to match patterns in strings.
Validate email addresses or other input formats using regex. -
String Comparison
Compare two strings for equality. -
String Palindrome
Check if a string is a palindrome. -
String Reverse
Reverse the characters of a string. -
Count Characters
Count occurrences of each character in a string. -
Capitalize Words
Capitalize the first letter of each word in a string. -
Trimming Whitespace
Remove leading and trailing whitespace from a string. -
String Compression
Compress a string by replacing consecutive characters with their counts. -
Anagrams
Check if two strings are anagrams of each other. -
String Rotation
Check if one string is a rotation of another string. -
Unicode Operations
Handle Unicode characters in strings. -
Substring Search
Implement substring search in a string. -
String Conversion
Convert between different string formats (camelCase, snake_case, kebab-case). -
String Split and Join
Split a string into an array of substrings and join them back. -
String Interpolation
Use string interpolation to construct dynamic strings. -
String Permutations
Generate all permutations of a string. -
Substring Frequency
Count occurrences of a substring in a string. -
String Padding
Pad a string to a specified length with another string.
-
Object Creation
Create an object with properties and methods.
Define and access object properties. -
Object Manipulation
Modify object properties.
Iterate through object properties using loops or Object.keys(). -
Object Oriented Programming
Implement inheritance and polymorphism using prototypes or classes.
Create constructor functions and instantiate objects. -
Object Comparison
Compare two objects for equality. -
Object Serialization
Serialize an object into JSON and deserialize JSON back into an object. -
Object Cloning
Create a deep clone of an object. -
Object Composition
Combine multiple objects into a single object. -
Object Iteration
Iterate over object properties using for...in loops. -
Object Freeze and Seal
Use Object.freeze() and Object.seal() to control object mutability. -
Nested Objects
Work with deeply nested objects and access nested properties. -
Object Property Deletion
Delete properties from an object. -
Object Conversion
Convert objects to primitive values using toString() and valueOf(). -
Object Destructuring
Use object destructuring to extract values into variables. -
Immutable Objects
Implement immutability in objects. -
Object Merge
Merge properties of two objects into a new object. -
Object Validation
Validate object properties against a schema or rules. -
Object Polymorphism
Implement polymorphic behavior using objects. -
Object Map
Map values of an object to another format. -
Object Deep Comparison
Compare nested objects deeply for equality. -
Object Properties
Access and manipulate object properties dynamically.
-
Function Basics
Define a function that takes parameters and returns a value.
Write functions with default parameters and rest parameters. -
Function Scope
Understand variable scope inside and outside functions.
Recognize and explain function and variable hoisting. -
Higher Order Functions
Use higher-order functions like map(), filter(), reduce() to manipulate arrays.
Implement functions that return other functions (closures). -
Recursion
Write recursive functions to solve problems like factorial calculation or Fibonacci sequence generation. -
Callback Functions
Use callback functions to handle asynchronous operations. -
Function Composition
Compose functions together to create new functions. -
Currying
Implement currying in functions. -
Memoization
Cache function results for performance optimization. -
Function Bind
Use Function.prototype.bind() to bind context to a function. -
Function Return Types
Define and enforce return types for functions. -
Function Overloading
Simulate function overloading in JavaScript. -
Partial Application
Implement partial application of functions. -
Anonymous Functions
Use anonymous functions for one-time use. -
IIFE (Immediately Invoked Function Expression)
Use IIFE to create local scopes and avoid polluting the global namespace. -
Async Functions
Define and use async functions with async/await. -
Generator Functions
Use generator functions to control iterative flows. -
Function Timing
Measure execution time of functions. -
Error Handling in Functions
Handle errors gracefully within functions. -
Function Parameters Validation
Validate function parameters before execution. -
Function Memoization
Implement memoization to optimize recursive functions.
-
Arrow Functions
Convert traditional functions to arrow functions.
Use arrow functions with implicit and explicit return. -
Template Literals
Use template literals for string interpolation.
Multiline strings with template literals. -
Let and Const
Understand block scoping with let and const.
Use const for constants that should not be reassigned. -
Destructuring
Destructure arrays and objects to extract values into variables.
Use destructuring in function parameters and for variable assignment. -
Modules
Import and export modules using ES6 syntax (import/export).
Create and use modules to organize code into reusable components. -
Classes
Define classes and create instances using constructor and methods.
Implement inheritance using extends and super keywords. -
Promises
Use Promises for asynchronous operations.
Chain promises using then() and handle errors with catch(). -
Async/Await
Simplify asynchronous code using async functions and await keyword. -
Rest and Spread Operators
Use rest parameters and spread operator for function arguments and array/object manipulation. -
Set and Map
Use Set and Map data structures for unique collections and key-value mappings. -
Symbols
Define and use symbols as unique object keys. -
Generators
Use generators to control iterative flows. -
Proxy Objects
Create and use Proxy objects for meta-programming. -
Default Parameters
Define default values for function parameters. -
Computed Property Names
Use computed property names in objects. -
Array Destructuring
Destructure arrays into individual variables. -
Object Destructuring
Destructure objects into individual variables. -
Promise.all and Promise.race
Use Promise.all() and Promise.race() for handling multiple promises. -
Optional Chaining
Safely access nested properties with optional chaining (?. operator). -
Nullish Coalescing Operator
Use nullish coalescing operator (??) to provide default values for null or undefined.
-
Sorting Algorithms
Implement various sorting algorithms (bubble sort, merge sort, quick sort). -
Searching Algorithms
Implement searching algorithms (binary search, linear search). -
Graph Algorithms
Implement graph traversal algorithms (DFS, BFS).
Solve problems involving shortest path algorithms (Dijkstra's algorithm). -
Dynamic Programming
Solve problems using dynamic programming techniques (fibonacci sequence, knapsack problem). -
Backtracking
Implement backtracking algorithms (N-Queens problem, Sudoku solver). -
Greedy Algorithms
Solve problems using greedy algorithms. -
Divide and Conquer
Apply divide and conquer strategy to solve problems. -
String Algorithms
Solve problems related to strings (substring search, palindrome detection). -
Array Algorithms
Solve problems related to arrays (subset generation, permutation). -
Mathematical Algorithms
Implement mathematical algorithms (factorial calculation, prime number generation). -
Tree Algorithms
Traverse trees and solve problems related to binary trees. -
Sorting Challenges
Solve specific challenges related to sorting. -
Graph Challenges
Solve specific challenges related to graph algorithms. -
Dynamic Programming Challenges
Solve specific challenges using dynamic programming. -
Geometry Algorithms
Implement algorithms related to computational geometry. -
Number Theory Algorithms
Solve problems related to number theory (GCD, LCM). -
Bit Manipulation
Solve problems using bit manipulation techniques. -
Combinatorial Algorithms
Solve problems involving combinations and permutations. -
Parallel Algorithms
Implement algorithms suitable for parallel execution. -
Optimization Problems
Solve optimization problems using algorithms.
-
Arrays
Implement basic array operations (insert, delete, update).
Use arrays to implement stack and queue data structures. -
Linked Lists
Implement singly linked lists.
Use linked lists to solve problems like reversing a list or detecting cycles. -
Stacks
Implement stack operations (push, pop, peek).
Use stacks to solve problems like balanced parentheses or postfix evaluation. -
Queues
Implement queue operations (enqueue, dequeue).
Use queues to solve problems like implementing a circular queue or a priority queue. -
Trees
Implement binary trees and binary search trees (BST).
Traverse trees using depth-first search (DFS) and breadth-first search (BFS). -
Heaps
Implement heap operations (insert, delete, heapify).
Use heaps to solve problems like implementing a priority queue. -
Hash Tables
Implement hash table operations (insert, delete, lookup).
Solve problems involving collisions and hash function design. -
Graphs
Implement graph representations (adjacency matrix, adjacency list).
Use graphs to solve problems like finding connected components or shortest paths. -
Tries
Implement tries (prefix trees) and solve problems like autocomplete. -
Disjoint Sets (Union-Find)
Implement disjoint-set data structure and solve related problems. -
Segment Trees
Implement segment trees and solve range query problems. -
Fenwick Trees (Binary Indexed Trees)
Implement Fenwick trees for efficient prefix sum calculations. -
Splay Trees
Implement splay trees and perform self-adjusting binary search. -
Suffix Trees and Arrays
Implement suffix trees and suffix arrays for pattern matching. -
Red-Black Trees
Implement red-black trees and maintain balance during insertion and deletion. -
B-Trees
Implement B-trees for disk-based data structures. -
Priority Queues
Implement priority queues using heaps or other suitable data structures. -
Sparse Matrices
Implement sparse matrices and perform operations efficiently. -
Persistent Data Structures
Implement persistent versions of basic data structures. -
Concurrency Structures
Implement data structures suitable for concurrent programming.
Feel free to fork this repository and add more problems or improve existing solutions. Happy coding! 🌟