JavaScript · Practice

Practical Projects

You learn JavaScript by building things. Start with a small, complete project, then move on to the guided projects in the project library.

Advanced 5 min Lesson 48 of 49 Runnable examples
Before you start:DOM ManipulationEvents
0/49 in JavaScript
On this page · 5 min · Advanced

Learning objectives#

  • Combine DOM, events and functions in one app
  • Validate input and format output
  • Plan a small project step by step
  • Choose your next project

Explanation#

Every small app follows the same loop: read input → calculate → display the result. Once you see the pattern, every project becomes easier.

Build in tiny steps: get the HTML on screen, wire up one event, log the values, then display them. Run it after every step.

Next projects to try, in order of difficulty: To-Do List (arrays + DOM), Quiz App (objects + events), Expense Tracker (reduce + localStorage), Weather Dashboard (fetch + async).

Code example: Mini project: tip calculator#

HTMLMini project: tip calculator Runnable
<style>
  body{font-family:system-ui;max-width:320px}
  label{display:block;margin:10px 0 4px} input,select{width:100%;padding:8px}
  #result{margin-top:16px;padding:12px;border-radius:10px;background:#eef2ff;font-weight:600}
</style>
<label for="bill">Bill amount (₹)</label>
<input id="bill" type="number" min="0" value="1200">
<label for="tip">Tip</label>
<select id="tip"><option value="0.05">5%</option><option value="0.1" selected>10%</option><option value="0.15">15%</option></select>
<label for="people">People</label>
<input id="people" type="number" min="1" value="3">
<div id="result"></div>


<script>
  const $ = id => document.getElementById(id);
  const inr = n => n.toLocaleString('en-IN', { style: 'currency', currency: 'INR' });


  function update() {
    const bill = Number($('bill').value), tip = Number($('tip').value), people = Number($('people').value);
    if (bill < 0 || people < 1) { $('result').textContent = 'Please enter a valid bill and at least 1 person.'; return; }
    const total = bill * (1 + tip);
    $('result').textContent = `Tip ${inr(bill * tip)} · Total ${inr(total)} · Each ${inr(total / people)}`;
  }
  ['bill', 'tip', 'people'].forEach(id => $(id).addEventListener('input', update));
  update();
</script>
Expected output
Tip ₹120.00 · Total ₹1,320.00 · Each ₹440.00 — updating live as you change the inputs.
Opens this example in the full playground

Step-by-step explanation#

  1. HTML provides three labelled inputs and a result box.
  2. update() reads the inputs and converts them to numbers.
  3. It validates, calculates the tip, total and share per person, and formats them as rupees.
  4. One input listener on each field keeps the result live; calling update() once shows the initial result.

Real-world use case#

Small, complete projects like this are perfect portfolio pieces and interview warm-ups.

Common mistakes#

Doing everything at once

Writing the whole app before running anything makes bugs hard to find. Build and test step by step.

Forgetting to convert input values

Input values are strings; "1200" + tip would join text instead of adding.

Best practices#

  • Plan the input → process → output flow first
  • Keep calculation logic in pure functions
  • Validate input and show helpful messages
  • Commit each working step to Git

Remember this#

Every app: read input → calculate → show result.

Run your code after every small step.

Finished small projects beat unfinished big ones.

Practice exercise#

Your task: Extend the tip calculator with a “Round up per person” checkbox that rounds each share up to the next ₹10.

Need a hint?
Math.ceil(share / 10) * 10
Show solution
JavaScript Illustrative
const share = total / people;
const final = $('round').checked ? Math.ceil(share / 10) * 10 : share;

Mini quiz#

Practical Projects quizMultiple choice Question 1 of 1

What is the best way to build a small project?

Score so far: 0/0

Want more? Practise all JavaScript MCQs · JavaScript interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.