🛠️ JavaScript Projects

Build Real Applications - From Idea to Deployment

Time to put your skills into practice! This projects course guides you through building complete JavaScript applications, from simple tools to complex web apps.

🎯 Project-Based Learning

Why build projects? Real learning happens when you create something useful. Each project teaches multiple concepts and gives you portfolio-worthy work.

Prerequisites: Complete the Beginner and Intermediate courses first.

📝 Project 1: Interactive Todo List

Your first complete JavaScript application

🎯 Project Overview

Build a fully functional todo list application that lets users add, complete, and delete tasks. This project combines DOM manipulation, events, and data persistence.

✨ Features to Build:
  • Add new todo items
  • Mark todos as complete/incomplete
  • Delete todos
  • Save todos to localStorage
  • Filter todos (all/active/completed)
  • Clear all completed todos

🏗️ Project Setup

📋 Step-by-Step Build Process:
  1. Create HTML structure - Form for adding todos, list for displaying them
  2. Add CSS styling - Make it look professional
  3. Implement add functionality - Handle form submission
  4. Add complete/delete buttons - Create interactive elements
  5. Implement localStorage - Save data between sessions
  6. Add filtering - Show all/active/completed todos

📄 HTML Structure

Todo List App

My Todo List

🎨 Basic CSS Styling

body { font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; background: #f5f5f5; } .container { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); } h1 { text-align: center; color: #333; } #todo-form { display: flex; margin-bottom: 20px; } #todo-input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 4px 0 0 4px; } button { padding: 10px 15px; background: #4CAF50; color: white; border: none; cursor: pointer; } #todo-form button { border-radius: 0 4px 4px 0; } .todo-item { display: flex; align-items: center; padding: 10px; border-bottom: 1px solid #eee; } .todo-item.completed .todo-text { text-decoration: line-through; color: #888; } .todo-text { flex: 1; } .delete-btn { background: #f44336; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer; }

⚙️ JavaScript Implementation

// DOM elements const todoForm = document.getElementById('todo-form'); const todoInput = document.getElementById('todo-input'); const todoList = document.getElementById('todo-list'); const filterButtons = document.querySelectorAll('.filter-btn'); const clearCompletedBtn = document.getElementById('clear-completed'); // Load todos from localStorage let todos = JSON.parse(localStorage.getItem('todos')) || []; // Save todos to localStorage function saveTodos() { localStorage.setItem('todos', JSON.stringify(todos)); } // Render todos function renderTodos(filter = 'all') { todoList.innerHTML = ''; let filteredTodos = todos; if (filter === 'active') { filteredTodos = todos.filter(todo => !todo.completed); } else if (filter === 'completed') { filteredTodos = todos.filter(todo => todo.completed); } filteredTodos.forEach((todo, index) => { const li = document.createElement('li'); li.className = 'todo-item' + (todo.completed ? ' completed' : ''); li.innerHTML = ` ${todo.text} `; todoList.appendChild(li); }); } // Add new todo todoForm.addEventListener('submit', (e) => { e.preventDefault(); const text = todoInput.value.trim(); if (text) { todos.push({ text, completed: false }); saveTodos(); renderTodos(); todoInput.value = ''; } }); // Handle todo actions (complete/delete) todoList.addEventListener('click', (e) => { const index = e.target.dataset.index; if (e.target.type === 'checkbox') { todos[index].completed = e.target.checked; saveTodos(); renderTodos(); } else if (e.target.classList.contains('delete-btn')) { todos.splice(index, 1); saveTodos(); renderTodos(); } }); // Filter todos filterButtons.forEach(button => { button.addEventListener('click', () => { filterButtons.forEach(btn => btn.classList.remove('active')); button.classList.add('active'); renderTodos(button.dataset.filter); }); }); // Clear completed todos clearCompletedBtn.addEventListener('click', () => { todos = todos.filter(todo => !todo.completed); saveTodos(); renderTodos(); }); // Initial render renderTodos();

🚀 Todo List Challenge Extensions:

🌤️ Project 2: Weather Dashboard

Build an app that fetches and displays weather data

🎯 Project Overview

Create a beautiful weather dashboard that shows current weather and forecasts. Learn about APIs, async JavaScript, and data visualization.

✨ Features to Build:
  • Search for cities
  • Display current weather
  • Show 5-day forecast
  • Weather icons and animations
  • Save favorite cities
  • Geolocation support

🌐 Working with APIs

Think of APIs like a restaurant menu.

You don't need to know how the food is prepared - you just order from the menu and get your meal. APIs provide data and services without you needing to know the implementation details.

// Fetch current weather async function getCurrentWeather(city) { try { const API_KEY = 'your_api_key_here'; const response = await fetch( `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${API_KEY}&units=metric` ); if (!response.ok) { throw new Error('City not found'); } const data = await response.json(); return data; } catch (error) { console.error('Error fetching weather:', error); throw error; } } // Fetch 5-day forecast async function getForecast(city) { const API_KEY = 'your_api_key_here'; const response = await fetch( `https://api.openweathermap.org/data/2.5/forecast?q=${city}&appid=${API_KEY}&units=metric` ); const data = await response.json(); return data; } // Usage async function displayWeather(city) { try { const currentWeather = await getCurrentWeather(city); const forecast = await getForecast(city); updateWeatherUI(currentWeather); updateForecastUI(forecast); } catch (error) { displayError(error.message); } }

🗺️ Geolocation Feature

// Get user's current location function getCurrentLocation() { return new Promise((resolve, reject) => { if (!navigator.geolocation) { reject(new Error('Geolocation not supported')); return; } navigator.geolocation.getCurrentPosition( position => { resolve({ lat: position.coords.latitude, lon: position.coords.longitude }); }, error => { reject(new Error('Unable to get location')); } ); }); } // Get weather by coordinates async function getWeatherByCoords(lat, lon) { const API_KEY = 'your_api_key_here'; const response = await fetch( `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${API_KEY}&units=metric` ); const data = await response.json(); return data; } // Auto-detect location weather async function loadLocalWeather() { try { const coords = await getCurrentLocation(); const weather = await getWeatherByCoords(coords.lat, coords.lon); updateWeatherUI(weather); } catch (error) { console.log('Could not get local weather:', error.message); } }

🧮 Project 3: Advanced Calculator

Build a fully functional calculator with history

🎯 Project Overview

Create a calculator that handles complex mathematical expressions, maintains calculation history, and includes scientific functions.

✨ Features to Build:
  • Basic arithmetic operations
  • Scientific functions (sin, cos, tan, log)
  • Calculation history
  • Keyboard support
  • Memory functions (M+, M-, MR, MC)
  • Expression evaluation

🔢 Expression Evaluation

// Simple expression evaluator function evaluateExpression(expression) { // Remove any dangerous characters expression = expression.replace(/[^0-9+\-*/().\s]/g, ''); try { // Use Function constructor for safe evaluation const result = new Function('return ' + expression)(); return result; } catch (error) { throw new Error('Invalid expression'); } } // Calculator class class Calculator { constructor() { this.display = ''; this.history = []; this.memory = 0; } appendNumber(number) { this.display += number; this.updateDisplay(); } appendOperator(operator) { this.display += operator; this.updateDisplay(); } clear() { this.display = ''; this.updateDisplay(); } calculate() { try { const result = evaluateExpression(this.display); this.history.push(`${this.display} = ${result}`); this.display = result.toString(); this.updateDisplay(); this.saveHistory(); } catch (error) { this.display = 'Error'; this.updateDisplay(); } } memoryAdd() { const currentValue = parseFloat(this.display) || 0; this.memory += currentValue; } memorySubtract() { const currentValue = parseFloat(this.display) || 0; this.memory -= currentValue; } memoryRecall() { this.display = this.memory.toString(); this.updateDisplay(); } memoryClear() { this.memory = 0; } updateDisplay() { document.getElementById('display').value = this.display; } saveHistory() { localStorage.setItem('calcHistory', JSON.stringify(this.history)); } loadHistory() { const saved = localStorage.getItem('calcHistory'); if (saved) { this.history = JSON.parse(saved); } } } // Initialize calculator const calculator = new Calculator(); calculator.loadHistory();

🧠 Project 4: Interactive Quiz App

Create an engaging quiz with multiple question types

🎯 Project Overview

Build a complete quiz application with different question types, scoring, and progress tracking. Learn about state management and user experience.

✨ Features to Build:
  • Multiple choice questions
  • True/false questions
  • Progress tracking
  • Score calculation
  • Review answers
  • Timer functionality

📊 Quiz Data Structure

const quizData = [ { question: "What does 'DOM' stand for?", type: "multiple-choice", options: [ "Document Object Model", "Data Object Management", "Dynamic Object Method", "Document Orientation Mode" ], correctAnswer: 0, explanation: "DOM stands for Document Object Model, which represents the structure of HTML documents." }, { question: "JavaScript is a case-sensitive language.", type: "true-false", correctAnswer: true, explanation: "Yes, JavaScript is case-sensitive, meaning 'hello' and 'Hello' are different." }, { question: "Which method adds an element to the end of an array?", type: "multiple-choice", options: ["push()", "pop()", "shift()", "unshift()"], correctAnswer: 0, explanation: "The push() method adds one or more elements to the end of an array." } ]; class Quiz { constructor(questions) { this.questions = questions; this.currentQuestionIndex = 0; this.score = 0; this.answers = []; this.timeLeft = 300; // 5 minutes this.timer = null; } startQuiz() { this.startTimer(); this.showQuestion(); } showQuestion() { const question = this.questions[this.currentQuestionIndex]; // Update UI with question data this.updateProgress(); } checkAnswer(answer) { const question = this.questions[this.currentQuestionIndex]; const isCorrect = answer === question.correctAnswer; this.answers.push({ question: question.question, userAnswer: answer, correctAnswer: question.correctAnswer, isCorrect: isCorrect, explanation: question.explanation }); if (isCorrect) { this.score++; } this.nextQuestion(); } nextQuestion() { this.currentQuestionIndex++; if (this.currentQuestionIndex < this.questions.length) { this.showQuestion(); } else { this.endQuiz(); } } startTimer() { this.timer = setInterval(() => { this.timeLeft--; this.updateTimer(); if (this.timeLeft <= 0) { this.endQuiz(); } }, 1000); } endQuiz() { clearInterval(this.timer); this.showResults(); } showResults() { const percentage = (this.score / this.questions.length) * 100; // Display results UI } }

📝 Project 5: Note-Taking Application

Build a full-featured notes app with rich text editing

🎯 Project Overview

Create a sophisticated note-taking app with categories, search, and rich text editing. Learn about complex state management and data persistence.

✨ Features to Build:
  • Create, edit, delete notes
  • Categorize notes
  • Search functionality
  • Rich text formatting
  • Auto-save
  • Export to different formats

💾 Advanced Data Persistence

class NotesApp { constructor() { this.notes = this.loadNotes(); this.currentNote = null; this.searchTerm = ''; this.selectedCategory = 'all'; this.initializeEventListeners(); this.renderNotes(); } loadNotes() { const saved = localStorage.getItem('notes'); return saved ? JSON.parse(saved) : []; } saveNotes() { localStorage.setItem('notes', JSON.stringify(this.notes)); } createNote(title = 'Untitled Note', content = '', category = 'general') { const note = { id: Date.now().toString(), title, content, category, createdAt: new Date(), updatedAt: new Date(), tags: [] }; this.notes.unshift(note); this.saveNotes(); return note; } updateNote(id, updates) { const note = this.notes.find(n => n.id === id); if (note) { Object.assign(note, updates, { updatedAt: new Date() }); this.saveNotes(); } } deleteNote(id) { this.notes = this.notes.filter(note => note.id !== id); this.saveNotes(); } searchNotes(term) { this.searchTerm = term.toLowerCase(); this.renderNotes(); } filterByCategory(category) { this.selectedCategory = category; this.renderNotes(); } getFilteredNotes() { return this.notes.filter(note => { const matchesSearch = !this.searchTerm || note.title.toLowerCase().includes(this.searchTerm) || note.content.toLowerCase().includes(this.searchTerm); const matchesCategory = this.selectedCategory === 'all' || note.category === this.selectedCategory; return matchesSearch && matchesCategory; }); } exportNotes() { const data = { notes: this.notes, exportedAt: new Date(), version: '1.0' }; const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'notes-export.json'; a.click(); URL.revokeObjectURL(url); } }

🚀 Deployment & Next Steps

Get your projects online and continue learning

🌐 Deploying Your Projects

📦 Free Hosting Options:

🎯 Continue Your JavaScript Journey

🚀 What's Next?

🎉 Congratulations!

You've completed the JavaScript Projects course!

You now have the skills to build real-world JavaScript applications. Keep coding, keep learning, and most importantly - keep building!

📚 Additional Resources