The coding challenge of the day from freeCodeCamp.
This repository contains my personal solutions to the Daily Coding Challenges from the freeCodeCamp "Daily Coding Challenge Archive".
The goal of this project is to consistently practice problem-solving, improve my JavaScript skills, project setup, and testing LLMs (commands, docJS, test jest, etc.).
- freeCodeCamp - Daily Coding Challenges
This repository serves as:
- Learning Platform: Daily practice with algorithmic problems
- Progress Tracker: Organized solutions for my purposes
- Code Quality Showcase: Modern JavaScript with professional tooling setup
- LLM testing sandbox: The repository is also used to explore and test how large language models (LLMs) can assist with problem solving, code generation, and documentation workflows in real projects.
- Beginner-friendly template: This project doubles as a template for beginner JavaScript developers β it demonstrates file structure, testing, and professional tooling so newcomers can learn a practical workflow.
- Real-work workspace: Challenges are generally simple, but the repository provides a full professional workspace (linting, formatting, hooks, tests) so you can solve exercises in an environment that mirrors real JS development.
Key Features:
- Modern ES6+ JavaScript implementation
- Comprehensive testing setup
- Automated code quality checks
- Organized file structure for scalability
- Professional development workflow
To create your own copy of this project for your solutions, we recommend using it as a template.
Step 1: Create a New Repository from this Template
- Click the "Use this template" button at the top of the repository page.
- Give your new repository a name and click "Create repository from template".
- This will create a new repository in your GitHub account with a clean history.
Step 2: Clone Your New Repository
git clone https://github.com/your-username/your-new-repository-name.git
cd your-new-repository-nameNow you can start adding your own solutions!
To keep your personal solutions separate from the template's core files and make updates easier, please follow this branching model:
-
main: This branch should mirror the original template. Keep it clean and use it only to pull in updates from the upstream (original) repository. Do not commit your solutions directly tomain. -
solutions/your-username: Create a personal branch starting frommainto store your solutions (e.g.,solutions/devmiczal). This isolates your work and prevents conflicts when updating the template.
Creating your solutions branch:
# Start from the main branch
git checkout main
# Create and switch to your new solutions branch
git checkout -b solutions/your-usernameFrom time to time, the original template might receive updates to configuration files or tools. To pull these changes into your project, you need to configure an "upstream" remote.
Step 1: Add the Upstream Remote (Only Once)
In your terminal, inside your project folder, run this command:
git remote add upstream https://github.com/devmiczal/freecodecamp-challenges.gitStep 2: Fetch and Merge Updates
Note: After updating the project (after performing merge/rebase), run
npm installto install or update dependencies if there are new or changed configuration files (e.g.,package.json,package-lock.json).
When you want to update your repository with the latest changes from the template:
# 1. Make sure your own work is committed on your solutions branch
git checkout solutions/your-username
git add .
git commit -m "feat: Save my latest solutions"
# 2. Switch to your main branch
git checkout main
# 3. Fetch and merge the latest template changes
git fetch upstream
git merge upstream/main
# Note: If you see an error "fatal: refusing to merge unrelated histories" on your first update,
# this is expected because you started from a template. Run this command instead:
git merge upstream/main --allow-unrelated-histories
# You only need to do this once. All future merges will work with the standard command.
# 4. Update your solutions branch with the new template changes
git checkout solutions/your-username
git rebase main # This is the recommended way to apply your changes on top of the latest templateIf you encounter any merge conflicts, resolve them, and then continue the rebase with git rebase --continue.
The challenges are organized by year, month, and day under the src directory for clarity and scalability:
freecodecamp-challenges/
βββ .lintstagedrc.json
βββ .nvmrc
βββ .prettierignore
βββ .prettierrc.json
βββ eslint.config.mjs
βββ LICENSE
βββ package.json
βββ package-lock.json
βββ README.md
βββ .ai/
β βββ llm_instructions.md
βββ .git/
βββ .github/
β βββ copilot-instructions.md
βββ .husky/
β βββ pre-commit
β βββ _/
βββ .vscode/
β βββ extensions.json
β βββ settings.json
βββ docs/
β βββ history-commands.md
β βββ project-decisions.md
βββ src/
βββ 2025/
βββ 08/
β βββ 2025-08-31--hex-generator.js
β βββ 2025-08-31--hex-generator.test.js
βββ 09/
βββ 2025-09-01--tribonacci-sequence.js
βββ 2025-09-01--tribonacci-sequence.test.jsFile Naming Convention:
- Source File:
src/YYYY/MM/YYYY-MM-DD--challenge-name.js - Test File:
src/YYYY/MM/YYYY-MM-DD--challenge-name.test.js
Where:
YYYY: The full year (e.g., 2025)MM: The two-digit month (e.g., 08 for August)YYYY-MM-DD: The full date of the challengechallenge-name: A descriptive, kebab-case name for the challenge
Example:
src/2025/08/2025-08-31--reverse-a-string.js
src/2025/08/2025-08-31--reverse-a-string.test.js
This project uses modern JavaScript (ES6+) and is configured with the following tools to ensure code quality and consistency:
- Node.js: JavaScript runtime (v22+)
- ESLint: Pluggable linter for identifying and reporting patterns
- Prettier: Opinionated code formatter for consistent style
- Husky: Git hooks management
- lint-staged: Pre-commit linting for staged files
- Jest: Testing framework
- Node.js
- Version 22 or later
- My setup is 24
- npm: Version 11 or later
- Git: For version control and hooks
Modern flat config setup (eslint.config.mjs) with:
- ES6+ syntax support
- Node.js and browser globals
- Prettier integration
- Custom rules for code quality
VS Code recommendation: install the "ESLint" extension (dbaeumer.vscode-eslint) to get on-save linting and quick fixes in the editor.
# Run ESLint
npx eslint .
# Fix auto-fixable issues
npx eslint . --fixConsistent code formatting with .prettierrc.json:
- 2-space indentation
- Single quotes
- Semicolons
- 110 character line width
- Others
Recommended VS Code extension: "Prettier - Code formatter" (esbenp.prettier-vscode) for consistent editor formatting and integration with the project's Prettier config.
# Format code
npx prettier --write .
# Check formatting
npx prettier --check .Pre-commit hooks ensure code quality:
- Runs ESLint on staged files
- Applies Prettier formatting
- Prevents bad code from entering repository
https://typicode.github.io/husky/getting-started.html
# Fix executable permissions
chmod ug+x .husky/* && chmod ug+x .git/hooks/*
# Initialize Husky
npx husky init && npm install
# Alternative if issues persist
npx husky && npm install- Create new challenge file: Follow naming convention (e.g.,
YYYY-MM-DD--challenge.js). - Implement solution: Use modern JavaScript with proper documentation.
- Write tests: Create a corresponding
*.test.jsfile in the same directory. - Run quality checks: ESLint and Prettier automatically run on commit.
- Commit changes: Husky ensures code quality before commit.
Each challenge is a standalone JavaScript file. Run with Node.js:
# Run specific challenge
node src/2025/08/2025-08-01--two-sum.js
# Run with debugging
node --inspect src/2025/08/2025-08-01--two-sum.jsTest files are located next to the source files they are testing.
# Run a specific test file
npm test src/2025/08/2025-08-01--two-sum.test.js
# Run all tests
npm test
# Run tests in watch mode
npm run test:watchTest File Template:
// src/YYYY/MM/YYYY-MM-DD--challenge-name.test.js
import { solutionFunction } from './YYYY-MM-DD--challenge-name.js';
describe('Challenge Name', () => {
test('should solve a basic case', () => {
expect(solutionFunction(input)).toBe(expectedOutput);
});
});Automated Checks:
- Pre-commit: lint-staged runs ESLint + Prettier
- CI/CD Ready: Configuration supports GitHub Actions
- Type Safety: JSDoc comments for better documentation
Manual Commands:
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Check formatting
npm run format:check- Use modern ES6+ features (arrow functions, destructuring, template literals)
- Prefer
constandletovervar - Write self-documenting code with meaningful variable names
- Include JSDoc for complex functions
- Handle edge cases and errors appropriately
/**
* Challenge: [Title]
* Date: YYYY-MM-DD
* Difficulty: [Easy/Medium/Hard]
* Time Complexity: O(?)
* Space Complexity: O(?)
*/
const solutionFunction = (input) => {
// Implementation with comments
};
// Test examples
console.log(solutionFunction(testCase)); // Expected: result
export { solutionFunction };- Array manipulation and searching
- String processing and pattern matching
- Mathematical computations
- Data structure implementations
- Recursion and dynamic programming
- Sorting and searching algorithms
- Tree and graph traversal
For AI assistants helping with this project, see llm_instructions.md for:
- Code standards and preferences
- Solution approach guidelines
- Testing requirements
- File structure conventions
- Communication style preferences
This is a personal learning project, but feedback and suggestions are welcome:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Follow the established code style and naming conventions
- Test your changes thoroughly
- Commit with clear, descriptive messages
- Submit a pull request
Contribution Guidelines:
- Ensure code passes all ESLint rules
- Include tests for new functionality
- Follow the established file naming convention
- Add JSDoc documentation for complex functions
These are personal solutions developed for learning purposes. They may not always represent the most optimal approach, but reflect my understanding and problem-solving approach at the time of implementation.
The solutions prioritize:
- Correctness: Solving the problem as specified
- Readability: Clear, maintainable code
- Learning: Demonstrating understanding of concepts
- Performance: Optimized where beneficial
This project is licensed under the MIT License. See the LICENSE file for details.
Happy Coding! π
"The only way to learn a new programming language is by writing programs in it." - Dennis Ritchie