Practical JavaScript Exercises, Language Fundamentals & Advanced Engineering Concepts
A focused collection of JavaScript implementations designed to develop problem-solving ability, strengthen language fundamentals, and understand JavaScript runtime behavior.
This repository is a structured JavaScript learning and problem-solving workspace.
It focuses on two complementary areas:
- JavaScript Fundamentals: Language syntax, data structures, functions, control flow, and core programming concepts.
- Advanced JavaScript: Closures, asynchronous execution, prototypes, iterators, generators, runtime behavior, and performance considerations.
The objective is to develop the ability to understand a problem, implement a correct solution, evaluate edge cases, and explain the underlying JavaScript behavior.
javascript-1111-problems/
│
├── js-basic/
│ ├── README.md
│ ├── array.js
│ ├── function.js
│ ├── loops.js
│ └── ...
│
├── js-advanced/
│ ├── README.md
│ ├── async-await.js
│ ├── closures.js
│ ├── event-loop.js
│ ├── prototypes.js
│ └── ...
│
├── LICENSE
└── README.md
Each directory has a distinct learning objective. Examples should be organized by concept rather than accumulated without a clear structure.
The js-basic/ directory develops a strong understanding of the language's core features.
| Category | Concepts |
|---|---|
| Variables | var, let, const |
| Data Types | Primitive and reference types |
| Operators | Arithmetic, comparison, logical |
| Control Flow | Conditions and switch statements |
| Loops | for, while, for...of, for...in |
| Functions | Declarations, expressions, arrow functions |
| Arrays | Iteration, transformation, searching |
| Objects | Properties, methods, object operations |
| Scope | Global, function, block, lexical scope |
| Strings | Manipulation, searching, formatting |
Learning objective: Understand how JavaScript works before relying on abstractions or frameworks.
The js-advanced/ directory explores deeper language behavior and practical programming patterns.
| Category | Concepts |
|---|---|
| Functions | Higher-order functions, currying, composition |
| Closures | Lexical environments and encapsulation |
| Asynchronous JavaScript | Promises, async/await, concurrency |
| Event Loop | Call stack, tasks, microtasks |
| Prototypes | Prototype chains, inheritance, delegation |
| Iterators | Iteration protocols and custom iterators |
| Generators | Lazy evaluation and incremental processing |
| Modules | ESM and CommonJS |
| Memory | Allocation, references, memory behavior |
| Performance | Time complexity, space complexity, benchmarking |
Learning objective: Understand JavaScript beyond syntax, including execution behavior, architectural choices, and engineering trade-offs.
Every problem should encourage a structured approach to implementation.
Understand the Problem
|
v
Identify Requirements
|
v
Analyze Edge Cases
|
v
Design the Solution
|
v
Implement
|
v
Test and Verify
|
v
Analyze Complexity
|
v
Explain the Solution
The emphasis is on understanding why a solution works rather than simply reaching the expected output.
Solutions should follow consistent engineering principles.
- Correctness: Handle the intended requirements and relevant edge cases.
- Readability: Prefer clear names and straightforward implementations.
- Single Responsibility: Keep examples focused on their primary concept.
- Maintainability: Avoid unnecessary complexity and duplication.
- Reusability: Extract reusable logic when it improves clarity.
- Consistency: Follow established naming and formatting conventions.
- Testability: Make expected behavior easy to verify.
A simple problem should have a clear implementation:
function findMaximum(numbers) {
if (!Array.isArray(numbers) || numbers.length === 0) {
throw new TypeError("Expected a non-empty array.");
}
return numbers.reduce((maximum, current) => {
return current > maximum ? current : maximum;
});
}
console.log(findMaximum([12, 45, 8, 67, 23]));
// 67The goal is not to make simple solutions unnecessarily complicated.
Problem implementations should consider relevant boundary conditions.
| Category | Examples |
|---|---|
| Empty input | "", [], {} |
| Nullish values | null, undefined |
| Numeric boundaries | 0, -1, Number.MAX_SAFE_INTEGER |
| Invalid input | Unexpected types and malformed values |
| Collections | Duplicate values and large datasets |
| Asynchronous behavior | Rejections, timeouts, cancellation |
Not every problem requires every edge case. Testing should reflect the actual requirements.
Performance should be evaluated using appropriate measurements and complexity analysis.
Important considerations:
- Time complexity.
- Space complexity.
- Input size.
- Memory allocation.
- Algorithmic trade-offs.
- Runtime environment.
- Benchmark methodology.
Example:
Linear Search O(n)
Binary Search O(log n)
Nested Traversal O(n²)
Complexity analysis should explain how an implementation scales as input size increases.
Performance claims should be supported by reproducible measurements rather than assumptions.
- Node.js
- Git
- Visual Studio Code (recommended)
git clone https://github.com/md-abu-kayser/javascript-1111-problems.git
cd javascript-1111-problemscd js-basic
node array.jscd ../js-advanced
node async-await.jsReplace the example filenames with files available in the respective directories.
Solutions should be verified against expected behavior.
For reusable functions, prioritize:
- Normal input.
- Empty input.
- Boundary conditions.
- Invalid input.
- Unexpected behavior.
The native Node.js test runner is a suitable option for automated tests.
Documentation: https://nodejs.org/api/test.html
Use the following workflow when studying an example:
- Read: Understand the problem and implementation.
- Predict: Determine the expected output before execution.
- Execute: Run the code using Node.js.
- Investigate: Understand unexpected results.
- Modify: Experiment with different inputs.
- Reimplement: Solve the problem independently.
- Explain: Describe the implementation and its trade-offs.
Being able to independently reproduce and explain a solution is more meaningful than simply recognizing it.
Contributions should improve the repository's technical or educational value.
- Keep examples focused on one primary concept.
- Use descriptive
kebab-casefilenames. - Prefer native JavaScript for language fundamentals.
- Include meaningful comments where necessary.
- Verify the expected output.
- Consider relevant edge cases.
- Avoid duplicated or unnecessarily complicated implementations.
- The problem has a clear objective.
- The implementation is correct.
- The code is readable and maintainable.
- Relevant edge cases are considered.
- The example executes successfully.
- No unnecessary dependencies are introduced.
- Documentation is updated when necessary.
| Resource | Purpose |
|---|---|
| MDN JavaScript | Language documentation |
| ECMAScript Specification | Official language specification |
| Node.js Documentation | Runtime documentation |
| JavaScript.info | Structured JavaScript learning |
| V8 Documentation | JavaScript engine concepts |
This project is licensed under the MIT License.
Md Abu Kayser
Full-Stack Engineer
GitHub
·
Email
Understand deeply. Solve thoughtfully. Write better JavaScript.