|
| 1 | +# JS Challenge Lab 🚀 |
| 2 | + |
| 3 | +**Tagline:** *Sharpen your JavaScript skills — one random question at a time.* |
| 4 | + |
| 5 | +A modern, interactive web application for practicing JavaScript concepts through randomized coding challenges. Perfect for developers looking to improve their JavaScript knowledge with hands-on practice. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## ✨ Features |
| 10 | + |
| 11 | +### 🎯 Core Functionality |
| 12 | +- **Random Question Generator**: Practice with questions covering arrays, scope, closures, promises, and more |
| 13 | +- **Difficulty Levels**: Choose from Beginner, Intermediate, or Advanced challenges |
| 14 | +- **Category Filtering**: Focus on specific topics like Functions, Objects, Async/Await, etc. |
| 15 | +- **Interactive Code Editor**: Powered by Monaco Editor with syntax highlighting and auto-formatting |
| 16 | +- **Real-time Code Execution**: Run your JavaScript code safely in a sandboxed environment |
| 17 | +- **Instant Feedback**: Compare your output with expected results |
| 18 | + |
| 19 | +### 🎮 Learning Features |
| 20 | +- **Smart Hint System**: Get contextual hints when you're stuck |
| 21 | +- **Detailed Explanations**: Understand the "why" behind each answer |
| 22 | +- **Progress Tracking**: Monitor your score and current streak |
| 23 | +- **Gamification**: Streak counters and score tracking to keep you motivated |
| 24 | + |
| 25 | +### 🎨 User Experience |
| 26 | +- **Dark/Light Mode**: Toggle between themes for comfortable coding |
| 27 | +- **Responsive Design**: Works seamlessly on desktop, tablet, and mobile |
| 28 | +- **Clean Interface**: Distraction-free environment focused on learning |
| 29 | + |
| 30 | +## 🛠️ Tech Stack |
| 31 | + |
| 32 | +| Purpose | Technology | |
| 33 | +|---------|------------| |
| 34 | +| **Frontend** | React 18 + Vite | |
| 35 | +| **Code Editor** | Monaco Editor (VS Code's editor) | |
| 36 | +| **Styling** | Material UI + Custom CSS | |
| 37 | +| **Icons** | Lucide React | |
| 38 | +| **Code Execution** | Safe JavaScript eval with custom console | |
| 39 | +| **Build Tool** | Vite | |
| 40 | + |
| 41 | +## 🚀 Getting Started |
| 42 | + |
| 43 | +### Prerequisites |
| 44 | +- Node.js 16+ |
| 45 | +- npm or yarn |
| 46 | + |
| 47 | +### Installation |
| 48 | + |
| 49 | +1. **Clone the repository** |
| 50 | + ```bash |
| 51 | + git clone <repository-url> |
| 52 | + cd js-challenge-lab |
| 53 | + ``` |
| 54 | + |
| 55 | +2. **Install dependencies** |
| 56 | + ```bash |
| 57 | + npm install |
| 58 | + ``` |
| 59 | + |
| 60 | +3. **Start the development server** |
| 61 | + ```bash |
| 62 | + npm run dev |
| 63 | + ``` |
| 64 | + |
| 65 | +4. **Open your browser** |
| 66 | + Navigate to `http://localhost:5173` (or the port shown in your terminal) |
| 67 | + |
| 68 | +### Building for Production |
| 69 | + |
| 70 | +```bash |
| 71 | +npm run build |
| 72 | +``` |
| 73 | + |
| 74 | +The built files will be in the `dist` directory, ready for deployment. |
| 75 | + |
| 76 | +## 📚 Question Categories |
| 77 | + |
| 78 | +- **Variables**: Basic variable assignment and primitives |
| 79 | +- **Arrays**: Array methods, manipulation, and iteration |
| 80 | +- **Strings**: String methods and manipulation |
| 81 | +- **Objects**: Object properties, methods, and references |
| 82 | +- **Functions**: Function declarations, expressions, and scope |
| 83 | +- **Scope**: Variable scope, hoisting, and closure concepts |
| 84 | +- **Closures**: Advanced closure patterns and use cases |
| 85 | +- **Promises**: Asynchronous programming with Promises |
| 86 | +- **Async/Await**: Modern async programming patterns |
| 87 | +- **Prototypes**: Prototype chain and inheritance |
| 88 | +- **Operators**: Type coercion and operator behavior |
| 89 | +- **Boolean**: Truthy/falsy values and boolean logic |
| 90 | +- **Array Methods**: map, filter, reduce, and other array methods |
| 91 | +- **Destructuring**: Object and array destructuring patterns |
| 92 | + |
| 93 | +## 🎯 How to Use |
| 94 | + |
| 95 | +1. **Select Your Level**: Choose from Beginner, Intermediate, or Advanced |
| 96 | +2. **Pick a Category**: Focus on specific JavaScript concepts or select "All" |
| 97 | +3. **Read the Question**: Understand what the code should output |
| 98 | +4. **Write/Modify Code**: Use the Monaco editor to write your solution |
| 99 | +5. **Run Your Code**: Click "Run Code" to execute and see results |
| 100 | +6. **Get Feedback**: Compare your output with the expected result |
| 101 | +7. **Learn More**: Use hints and explanations to understand concepts |
| 102 | +8. **Track Progress**: Monitor your score and maintain your streak! |
| 103 | + |
| 104 | +## 🔧 Project Structure |
| 105 | + |
| 106 | +``` |
| 107 | +src/ |
| 108 | +├── components/ |
| 109 | +│ ├── CodeEditor.jsx # Monaco editor wrapper |
| 110 | +│ ├── QuestionDisplay.jsx # Question rendering component |
| 111 | +│ ├── ResultDisplay.jsx # Results and feedback component |
| 112 | +│ └── ProgressBar.jsx # Progress tracking (optional) |
| 113 | +├── data/ |
| 114 | +│ └── questions.js # Question database |
| 115 | +├── App.jsx # Main application component |
| 116 | +├── index.css # Global styles and Tailwind imports |
| 117 | +└── main.jsx # React application entry point |
| 118 | +``` |
| 119 | + |
| 120 | +## 🎨 Customization |
| 121 | + |
| 122 | +### Adding New Questions |
| 123 | + |
| 124 | +Edit `src/data/questions.js` to add new challenges: |
| 125 | + |
| 126 | +```javascript |
| 127 | +{ |
| 128 | + id: 15, |
| 129 | + difficulty: "intermediate", |
| 130 | + category: "Arrays", |
| 131 | + question: "What will be the output of the following code?", |
| 132 | + starterCode: `const arr = [1, 2, 3]; |
| 133 | +console.log(arr.push(4));`, |
| 134 | + expectedOutput: "4", |
| 135 | + hint: "The push method returns the new length of the array.", |
| 136 | + explanation: "Array.push() adds elements to the end and returns the new length." |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +### Styling |
| 141 | + |
| 142 | +The app uses Tailwind CSS with custom color schemes defined in `tailwind.config.js`. You can customize: |
| 143 | +- Color palette |
| 144 | +- Dark mode behavior |
| 145 | +- Component styling |
| 146 | +- Responsive breakpoints |
| 147 | + |
| 148 | +### Code Execution |
| 149 | + |
| 150 | +The code execution system uses a safe `new Function()` approach with a mocked console object. For production use, consider additional security measures. |
| 151 | + |
| 152 | +## 🚦 Development Scripts |
| 153 | + |
| 154 | +- `npm run dev` - Start development server |
| 155 | +- `npm run build` - Build for production |
| 156 | +- `npm run preview` - Preview production build |
| 157 | +- `npm run lint` - Run ESLint |
| 158 | + |
| 159 | +## 🤝 Contributing |
| 160 | + |
| 161 | +1. Fork the repository |
| 162 | +2. Create a feature branch: `git checkout -b feature-name` |
| 163 | +3. Add your changes and new questions |
| 164 | +4. Commit your changes: `git commit -m 'Add feature'` |
| 165 | +5. Push to the branch: `git push origin feature-name` |
| 166 | +6. Submit a pull request |
| 167 | + |
| 168 | +### Ideas for Contributions |
| 169 | +- Add more JavaScript questions and categories |
| 170 | +- Implement user accounts and progress saving |
| 171 | +- Add support for TypeScript challenges |
| 172 | +- Create a leaderboard system |
| 173 | +- Add question difficulty ratings from users |
| 174 | +- Implement spaced repetition algorithm |
| 175 | + |
| 176 | +## 📝 License |
| 177 | + |
| 178 | +This project is open source and available under the [MIT License](LICENSE). |
| 179 | + |
| 180 | +## 🙏 Acknowledgments |
| 181 | + |
| 182 | +- Built with [React](https://reactjs.org/) and [Vite](https://vitejs.dev/) |
| 183 | +- Code editor powered by [Monaco Editor](https://microsoft.github.io/monaco-editor/) |
| 184 | +- Styled with [Tailwind CSS](https://tailwindcss.com/) |
| 185 | +- Icons from [Lucide](https://lucide.dev/) |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +**Happy Coding! 🎉** Start sharpening your JavaScript skills today with JS Challenge Lab! |
| 190 | + |
| 191 | +## React Compiler |
| 192 | + |
| 193 | +The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). |
| 194 | + |
| 195 | +## Expanding the ESLint configuration |
| 196 | + |
| 197 | +If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project. |
0 commit comments