Master front-end development with these comprehensive coding challenges covering HTML, CSS, JavaScript, React, and modern web development practices. From beginner DOM manipulation to advanced performance optimization techniques.
Junior Level Challenges
1. Responsive Navigation Bar
Difficulty: Beginner | Topics: HTML, CSS, JavaScript
Challenge: Create a responsive navigation bar that collapses into a hamburger menu on mobile devices with smooth animations.
document.querySelector('.nav-toggle').addEventListener('click', () => {
document.querySelector('.nav-menu').classList.toggle('active');
});
2. Interactive Image Carousel
Difficulty: Beginner | Topics: JavaScript, CSS, DOM Manipulation
Challenge: Build an image carousel with navigation dots, previous/next buttons, and auto-play functionality.
class Carousel {
constructor(container) {
this.currentSlide = 0;
this.slides = container.querySelectorAll('.carousel-slide');
this.init();
}
showSlide(n) {
this.slides[this.currentSlide].classList.remove('active');
this.currentSlide = (n + this.slides.length) % this.slides.length;
this.slides[this.currentSlide].classList.add('active');
}
}
3. Form Validation System
Difficulty: Beginner-Intermediate | Topics: JavaScript, Regular Expressions, UX
Challenge: Create a comprehensive form validation system with real-time feedback and custom error messages.
class FormValidator {
constructor(form) {
this.form = form;
this.rules = {
required: (value) => value.trim() !== '',
email: (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
};
}
validateField(field) {
const value = field.value;
const rules = field.dataset.rules.split('|');
return rules.every(rule => this.rules[rule](value));
}
}
4. CSS Grid Layout System
Difficulty: Intermediate | Topics: CSS Grid, Responsive Design
Challenge: Create a flexible grid layout system that adapts to different screen sizes.
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
.grid-item.featured {
grid-column: span 2;
}
@media (max-width: 768px) {
.grid-item.featured {
grid-column: span 1;
}
}
Mid-Level Challenges
5. API Data Fetching with Error Handling
Difficulty: Intermediate | Topics: JavaScript, Async/Await, Error Handling
Challenge: Create a robust API data fetching system with loading states, error handling, and retry logic.
class APIClient {
async fetchWithRetry(endpoint, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(endpoint);
if (!response.ok) throw new Error(`HTTP Error: ${response.status}`);
return await response.json();
} catch (error) {
if (attempt === maxRetries) throw error;
await this.wait(1000 * attempt);
}
}
}
wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
6. Local Storage Data Persistence
Difficulty: Intermediate | Topics: JavaScript, Local Storage, Data Management
Challenge: Create a local storage wrapper with expiration, data validation, and automatic cleanup.
class LocalStorageManager {
set(key, value, expirationHours = 24) {
const storageItem = {
value,
expiration: Date.now() + (expirationHours * 60 * 60 * 1000)
};
localStorage.setItem(key, JSON.stringify(storageItem));
}
get(key) {
const item = localStorage.getItem(key);
if (!item) return null;
const parsed = JSON.parse(item);
if (Date.now() > parsed.expiration) {
this.remove(key);
return null;
}
return parsed.value;
}
}
7. React Component with Custom Hooks
Difficulty: Advanced | Topics: React, Hooks, State Management
Challenge: Build a React component using custom hooks for data fetching and local storage.
function useLocalStorage(key, initialValue) {
const [value, setValue] = useState(() => {
try {
const item = localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;
} catch {
return initialValue;
}
});
const setStoredValue = useCallback((newValue) => {
setValue(newValue);
localStorage.setItem(key, JSON.stringify(newValue));
}, [key]);
return [value, setStoredValue];
}
Senior Level Challenges
8. Virtual DOM Implementation
Difficulty: Expert | Topics: JavaScript, Virtual DOM, Rendering
Challenge: Implement a simple virtual DOM with diffing algorithm and efficient updates.
class VirtualDOM {
createElement(type, props = {}, ...children) {
return {
type,
props: { ...props, children: children.flat() }
};
}
diff(oldTree, newTree) {
const patches = [];
this.diffWalk(oldTree, newTree, 0, patches);
return patches;
}
diffWalk(oldNode, newNode, index, patches) {
if (!oldNode) {
patches.push({ type: 'CREATE', newNode, index });
} else if (!newNode) {
patches.push({ type: 'REMOVE', index });
} else if (this.changed(oldNode, newNode)) {
patches.push({ type: 'REPLACE', newNode, index });
}
}
}
9. Infinite Scroll with Intersection Observer
Difficulty: Advanced | Topics: JavaScript, Performance, APIs
Challenge: Implement infinite scroll with performance optimization and error handling.
class InfiniteScroll {
constructor(container, options = {}) {
this.container = container;
this.currentPage = 1;
this.isLoading = false;
this.hasMore = true;
this.setupIntersectionObserver();
}
setupIntersectionObserver() {
this.observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && !this.isLoading && this.hasMore) {
this.loadMoreData();
}
});
}, { rootMargin: '100px' });
}
}
10. Debounced Search with Caching
Difficulty: Advanced | Topics: JavaScript, Performance, Caching
Challenge: Create a search system with debouncing, result caching, and keyboard navigation.
class SmartSearch {
constructor(input, resultsContainer, options = {}) {
this.input = input;
this.cache = new Map();
this.searchTimeout = null;
this.options = { debounceDelay: 300, ...options };
}
handleInput(value) {
clearTimeout(this.searchTimeout);
if (this.cache.has(value)) {
this.displayResults(this.cache.get(value));
return;
}
this.searchTimeout = setTimeout(() => {
this.performSearch(value);
}, this.options.debounceDelay);
}
}
11. Progressive Web App (PWA) Features
Difficulty: Expert | Topics: Service Workers, Caching, Offline
Challenge: Implement PWA features including service worker, offline functionality, and push notifications.
// Service Worker Registration
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js')
.then(registration => console.log('SW registered'))
.catch(error => console.log('SW registration failed'));
}
// Service Worker (sw.js)
self.addEventListener('install', event => {
event.waitUntil(
caches.open('v1').then(cache => {
return cache.addAll([
'/',
'/styles.css',
'/script.js'
]);
})
);
});
12. CSS-in-JS Component System
Difficulty: Advanced | Topics: CSS-in-JS, Component Architecture
Challenge: Build a CSS-in-JS system with dynamic styling and theme support.
class StyledComponent {
constructor(tag = 'div') {
this.tag = tag;
this.styles = {};
this.dynamicStyles = [];
}
styled(styles) {
this.styles = { ...this.styles, ...styles };
return this;
}
render(props = {}) {
const element = document.createElement(this.tag);
const computedStyles = this.computeStyles(props);
Object.assign(element.style, computedStyles);
return element;
}
computeStyles(props) {
return Object.entries(this.styles).reduce((acc, [key, value]) => {
acc[key] = typeof value === 'function' ? value(props) : value;
return acc;
}, {});
}
}


