---
title: "25 JavaScript Project Ideas for Beginners (Logic Tested)"
description: "25 JavaScript project ideas for beginners, intermediate and portfolio, with the core logic for 12 run in Node.js and real output shown."
slug: javascript-project-ideas-for-beginners
canonical: https://learn.modernagecoders.com/blog/javascript-project-ideas-for-beginners/
date: 2026-11-15
dateModified: 2026-11-15
category: "JavaScript"
tags: ["JavaScript", "Projects", "Beginners", "Portfolio"]
keywords: ["javascript project ideas for beginners", "javascript projects for beginners", "javascript project ideas intermediate", "javascript portfolio projects", "javascript projects with source code", "simple javascript projects", "javascript mini projects"]
readTime: "19 min read"
author: "Modern Age Coders Team"
---
# 25 JavaScript Project Ideas for Beginners, With Tested Logic

> Beginner, intermediate and portfolio ideas. For 12 of them we wrote the logic as plain functions and ran it in Node, so you can see it works before you build the page.

![JavaScript project ideas for beginners: 25 ideas with the logic for 12 tested in Node.js](/images/blog/javascript-project-ideas-for-beginners/00-hero.png)

*By Modern Age Coders Team · 2026-11-15 · 19 min read*

**Quick answer:** Beginner JavaScript projects include a tip splitter, live word counter, palindrome checker, rock paper scissors, age calculator and typing speed test. Intermediate projects include a Wordle clone, Markdown previewer, habit tracker and debounced search; portfolio projects include 2048, Minesweeper, Snake, visualisers, a chat app and a browser extension. For 12 of the 25 ideas, the core logic is written as plain functions and run in Node.js with real output, with honest notes on the browser parts that were not run.

Good JavaScript project ideas for beginners are small apps where the logic is simple but real: a tip splitter, a live word counter, a palindrome checker, rock paper scissors, an age calculator and a typing speed test. Intermediate projects add state and data, such as a Wordle clone, a Markdown previewer and a habit tracker, and portfolio projects are full games and tools such as 2048, Minesweeper or a real-time chat. Below are **25 JavaScript project ideas** in those three levels, and for 12 of them we wrote the core logic and ran it in Node.js, with the real output pasted.

This page takes a different angle from our [20 HTML, CSS and JavaScript project ideas](/blog/html-css-javascript-project-ideas), which focuses on building the page: layouts, forms and the DOM. Here the focus is the **logic**, the part that decides what the app actually does. Every tested project is written as plain functions with no `document` in them, so they run in Node, can be tested, and then need only a few lines to connect to a web page. We say clearly which parts need a browser and were not run.

> **How these were tested**

> Each logic file was run with `node` (version 22) and its output pasted exactly. Anything that touches the page (buttons, text boxes, canvas) cannot run in Node, so it is described in an "In the browser" note rather than shown as tested code. Where we do show a browser snippet, we only checked that it parses with `node --check`, and we say so.

## All 25 JavaScript project ideas at a glance

| No. | Project | Level | Core JavaScript skill | Logic tested in Node |
| --- | --- | --- | --- | --- |
| 1 | Tip and bill splitter | Beginner | numbers, rounding, Array.from | Yes |
| 2 | Live word counter | Beginner | regex, objects as counters | Yes |
| 3 | Palindrome checker | Beginner | strings, two pointers | Yes |
| 4 | Rock paper scissors lizard Spock | Beginner | rules as data | Yes |
| 5 | Exact age calculator | Beginner | Date objects | Yes |
| 6 | Random name picker | Beginner | Math.random, arrays | Idea |
| 7 | Unit converter | Beginner | functions, input events | Idea |
| 8 | Dice roller with history | Beginner | arrays, DOM lists | Idea |
| 9 | Pomodoro timer | Beginner | setInterval, state | Idea |
| 10 | Typing speed test | Beginner | string comparison, timing | Yes |
| 11 | Wordle clone | Intermediate | counting letters, two passes | Yes |
| 12 | Markdown previewer | Intermediate | regex replace, escaping HTML | Yes |
| 13 | Habit tracker with streaks | Intermediate | dates, Set, sorting | Yes |
| 14 | Search as you type | Intermediate | debounce, timers, closures | Yes |
| 15 | GitHub profile finder | Intermediate | fetch, async/await, JSON | Idea |
| 16 | Flashcards with spaced repetition | Intermediate | localStorage, scheduling | Idea |
| 17 | Budget planner with charts | Intermediate | reduce, a chart library | Idea |
| 18 | Hangman with on-screen keyboard | Intermediate | event delegation | Idea |
| 19 | 2048 game | Portfolio | array transforms, game state | Yes |
| 20 | Minesweeper | Portfolio | 2D arrays, recursion | Yes |
| 21 | Snake on a canvas | Portfolio | canvas, requestAnimationFrame | Idea |
| 22 | Sorting algorithm visualiser | Portfolio | generators, animation | Idea |
| 23 | Pathfinding visualiser | Portfolio | BFS and A*, grids | Idea |
| 24 | Real-time chat app | Portfolio | Node.js, WebSockets | Idea |
| 25 | Browser extension | Portfolio | extension APIs, storage | Idea |

## The habit that makes JavaScript projects easier: logic first, page second

Beginners often start a project by writing `document.querySelector` and an event listener, then cram all the thinking into the click handler. When something breaks, they cannot tell whether the bug is in the maths or in the page. The fix is a simple split:

- **Logic:** pure functions that take values and return values. `splitBill(100, 15, 3)` returns `[38.34, 38.33, 38.33]` every time. No page needed, so you can run and test it in Node or the browser console.
- **Wiring:** a few lines that read inputs from the page, call the logic, and write the result back.
- **Think in examples first:** before writing a function, write three inputs and the outputs you expect, including an awkward one (zero people, an empty string, a repeated letter). The awkward case is where the real thinking is, and it is how you check AI-suggested code too.

![Logic first, page second: pure JavaScript functions are tested in Node with example inputs and outputs, then a few lines of DOM wiring connect them to buttons and text boxes in the browser](/images/blog/javascript-project-ideas-for-beginners/01-logic-first.png)

*Test the thinking where it is easy to test, then connect it to the page.*

## JavaScript project ideas for beginners

### 1. Tip and bill splitter

The beginner trap here is money and decimals: 115 split three ways is 38.333..., and if everyone pays 38.33 a cent goes missing. This version works in whole cents and gives the leftover cents to the first people, so the shares always add back up.

```javascript
// Split a bill with a tip, so the shares add back up exactly (no lost paise or cents).
function splitBill(total, tipPercent, people) {
  const totalCents = Math.round(total * 100 * (1 + tipPercent / 100));
  const base = Math.floor(totalCents / people);
  const extra = totalCents % people;            // the first `extra` people pay one cent more
  return Array.from({ length: people }, (_, i) => (base + (i < extra ? 1 : 0)) / 100);
}

const shares = splitBill(100, 15, 3);
console.log(shares);
console.log("adds up to", shares.reduce((a, b) => a + b, 0).toFixed(2));
console.log(splitBill(45.5, 10, 4));
```

**Output (logic run in Node.js 22)**

```text
$ node 01-bill-splitter.js
[ 38.34, 38.33, 38.33 ]
adds up to 115.00
[ 12.52, 12.51, 12.51, 12.51 ]
```

**In the browser:** three number inputs and a button; show each share in a list.

**Stretch goal:** let each person add a different tip, or split by what each person ordered.

### 2. Live word counter

Counts words, characters with and without spaces, reading time at 200 words a minute, and the most used word. The empty-string run checks the awkward case: no crash, and reading time never drops below one minute.

```javascript
// Live word counter: words, characters, reading time and the most used word.
function stats(text) {
  const words = text.toLowerCase().match(/[a-z']+/g) || [];
  const freq = {};
  for (const w of words) freq[w] = (freq[w] || 0) + 1;
  const [top = "", topCount = 0] = Object.entries(freq).sort((a, b) => b[1] - a[1])[0] || [];
  return {
    words: words.length,
    characters: text.length,
    charactersNoSpaces: text.replace(/\s/g, "").length,
    readingMinutes: Math.max(1, Math.ceil(words.length / 200)),
    topWord: `${top} (${topCount})`,
  };
}

console.log(stats("To be, or not to be, that is the question."));
console.log(stats(""));
```

**Output (logic run in Node.js 22)**

```text
$ node 02-word-counter.js
{
  words: 10,
  characters: 42,
  charactersNoSpaces: 33,
  readingMinutes: 1,
  topWord: 'to (2)'
}
{
  words: 0,
  characters: 0,
  charactersNoSpaces: 0,
  readingMinutes: 1,
  topWord: ' (0)'
}
```

**Browser wiring (not run in Node; parse-checked only)**

```javascript
// Browser only: connects stats() from 02-word-counter.js to the page.
// <textarea id="box"></textarea> <p id="result"></p>
const box = document.querySelector("#box");
const result = document.querySelector("#result");

box.addEventListener("input", () => {
  const s = stats(box.value);
  result.textContent = `${s.words} words, ${s.characters} characters, about ${s.readingMinutes} min to read. Top word: ${s.topWord}`;
});
```

**In the browser:** the wiring snippet above connects it to a text box. We checked that it parses with `node --check`; it needs a page to run.

**Stretch goal:** highlight words used more than three times, a handy tool for essay writing.

### 3. Palindrome checker

Cleans the text, then walks two pointers inward from both ends. That is less memory than reversing the string, and a pattern you will meet again in interview questions. The last example checks that text with no letters is not called a palindrome.

```javascript
// Palindrome checker that ignores case, spaces and punctuation.
function isPalindrome(text) {
  const clean = text.toLowerCase().replace(/[^a-z0-9]/g, "");
  let left = 0, right = clean.length - 1;
  while (left < right) {
    if (clean[left] !== clean[right]) return false;
    left++; right--;
  }
  return clean.length > 0;
}

for (const t of ["racecar", "A man, a plan, a canal: Panama", "JavaScript", "No lemon, no melon", "!!!"]) {
  console.log(JSON.stringify(t), "->", isPalindrome(t));
}
```

**Output (logic run in Node.js 22)**

```text
$ node 03-palindrome.js
"racecar" -> true
"A man, a plan, a canal: Panama" -> true
"JavaScript" -> false
"No lemon, no melon" -> true
"!!!" -> false
```

**In the browser:** a text box that turns green or red as you type.

**Stretch goal:** find the longest palindrome hidden inside a sentence.

### 4. Rock paper scissors lizard Spock

The rules live in an object, not in a chain of `if` statements. Adding two new moves was two lines of data, and `decide()` did not change at all.

```javascript
// Rock paper scissors: the rules as data, so adding "lizard" and "spock" is one line each.
const BEATS = {
  rock: ["scissors", "lizard"],
  paper: ["rock", "spock"],
  scissors: ["paper", "lizard"],
  lizard: ["spock", "paper"],
  spock: ["scissors", "rock"],
};

function decide(a, b) {
  if (a === b) return "draw";
  return BEATS[a].includes(b) ? "player 1" : "player 2";
}

const rounds = [["rock", "scissors"], ["paper", "scissors"], ["spock", "rock"], ["lizard", "lizard"]];
for (const [a, b] of rounds) console.log(`${a} vs ${b}: ${decide(a, b)}`);
```

**Output (logic run in Node.js 22)**

```text
$ node 04-rock-paper-scissors.js
rock vs scissors: player 1
paper vs scissors: player 2
spock vs rock: player 1
lizard vs lizard: draw
```

**In the browser:** five buttons, a computer move from `Math.random()`, and a running score.

**Stretch goal:** make the computer learn: pick the move that beats what the player chooses most often.

### 5. Exact age calculator

Years, months and days between two dates, borrowing days from the previous month when needed, so it copes with short months and 29 February. JavaScript months count from 0, which catches out almost everyone once; the comment says so.

```javascript
// Exact age in years, months and days between two dates (handles month lengths and leap years).
function age(birth, today) {
  let years = today.getFullYear() - birth.getFullYear();
  let months = today.getMonth() - birth.getMonth();
  let days = today.getDate() - birth.getDate();
  if (days < 0) {
    months--;
    // days in the month before `today`'s month
    days += new Date(today.getFullYear(), today.getMonth(), 0).getDate();
  }
  if (months < 0) { years--; months += 12; }
  return { years, months, days };
}

const today = new Date(2026, 10, 15);                // months count from 0: 10 is November
console.log(age(new Date(2012, 4, 20), today));
console.log(age(new Date(2008, 1, 29), today));     // born on 29 February
console.log(age(new Date(2026, 9, 31), today));
```

**Output (logic run in Node.js 22)**

```text
$ node 05-age-calculator.js
{ years: 14, months: 5, days: 26 }
{ years: 18, months: 8, days: 17 }
{ years: 0, months: 0, days: 15 }
```

**In the browser:** a date input; show the age and the number of days until the next birthday.

**Stretch goal:** show the day of the week the person was born.

### 6 to 9. More beginner ideas

- **Random name picker:** paste a list of names, pick one with `Math.random()`, and remove it so nobody is picked twice.
- **Unit converter:** convert as you type with the `input` event; keep each formula in its own function.
- **Dice roller with history:** roll, show the dice faces, and keep the last ten rolls in a list on the page.
- **Pomodoro timer:** 25 minutes work, 5 rest, with `setInterval`. Store the end time, not a counter, so the timer stays accurate when the tab is in the background.

### 10. Typing speed test

Standard typing-test maths: five characters count as one word, net speed subtracts errors per minute, and accuracy is correct characters over typed characters. The third run shows a real weakness: one missing letter shifts every later character, so accuracy falls to 29% for what is really a single mistake.

```javascript
// Typing speed test maths: words per minute (5 characters = 1 word) and accuracy.
function score(target, typed, seconds) {
  let correct = 0;
  for (let i = 0; i < typed.length; i++) if (typed[i] === target[i]) correct++;
  const minutes = seconds / 60;
  const grossWpm = typed.length / 5 / minutes;
  const errors = typed.length - correct;
  return {
    grossWpm: Math.round(grossWpm),
    netWpm: Math.max(0, Math.round(grossWpm - errors / minutes)),
    accuracy: typed.length ? `${Math.round((correct / typed.length) * 100)}%` : "0%",
  };
}

const target = "the quick brown fox jumps over the lazy dog";
console.log(score(target, "the quick brown fox jumps over the lazy dog", 12));
console.log(score(target, "the quick brown fax jumps ovar the lazy dig", 12));   // 3 wrong letters
console.log(score(target, "the quick brwn fox jumps over the lazy dog", 12));    // 1 missing letter
```

**Output (logic run in Node.js 22)**

```text
$ node 06-typing-test.js
{ grossWpm: 43, netWpm: 43, accuracy: '100%' }
{ grossWpm: 43, netWpm: 28, accuracy: '93%' }
{ grossWpm: 42, netWpm: 0, accuracy: '29%' }
```

**In the browser:** show the sentence, start the clock on the first key press, and stop it when the text matches.

**Stretch goal:** compare word by word instead of character by character, so one dropped letter costs one word, not the whole line.

## Intermediate JavaScript project ideas

These keep state, handle edge cases and often talk to the internet. They are where JavaScript starts to feel like real software.

### 11. Wordle clone

Scoring a guess looks easy until a letter repeats. The answer *apple* has two p's and so does the guess *paper*: one p is green, and the other may be yellow only because a second p is still unused. In *robot* against *otter*, the answer has one t, so only the first t in the guess turns yellow and the second stays grey. The fix is two passes: mark greens first and count the leftover letters, then hand out yellows only while letters remain.

```javascript
// Wordle scoring, including the tricky case of repeated letters.
// G = right letter, right place. Y = in the word, wrong place. . = not in the word (or already used up).
function scoreGuess(answer, guess) {
  const result = Array(5).fill(".");
  const left = {};
  for (let i = 0; i < 5; i++) {
    if (guess[i] === answer[i]) result[i] = "G";
    else left[answer[i]] = (left[answer[i]] || 0) + 1;    // letters still available for Y
  }
  for (let i = 0; i < 5; i++) {
    if (result[i] !== "G" && left[guess[i]] > 0) {
      result[i] = "Y";
      left[guess[i]]--;
    }
  }
  return result.join("");
}

for (const [answer, guess] of [["crane", "trace"], ["apple", "paper"], ["abbey", "babes"], ["robot", "otter"], ["light", "light"]]) {
  console.log(`${answer} / ${guess} -> ${scoreGuess(answer, guess)}`);
}
```

**Output (logic run in Node.js 22)**

```text
$ node 07-wordle-scoring.js
crane / trace -> .GGYG
apple / paper -> YYGY.
abbey / babes -> YYGG.
robot / otter -> YY..Y
light / light -> GGGGG
```

**In the browser:** a 6 by 5 grid of tiles and an on-screen keyboard that colours each key.

**Stretch goal:** add a hard mode that forces you to reuse letters you have already found.

![Wordle scoring with repeated letters: for the answer apple and the guess paper, the second p is green, the first p and the a and e are yellow, and r is grey, decided in two passes](/images/blog/javascript-project-ideas-for-beginners/02-wordle.png)

*Greens first, then yellows only while letters are left over.*

### 12. Markdown previewer

Turns headings, bold, italic, inline code, links and lists into HTML. Notice the last line: it escapes `<` and `>` *before* adding any tags, so a user cannot sneak a script into the page. Skipping that step is one of the most common security mistakes in beginner projects.

```javascript
// A tiny Markdown previewer: headings, bold, italic, inline code, links and lists.
function escapeHtml(s) {
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}

function inline(s) {
  return escapeHtml(s)
    .replace(/`([^`]+)`/g, "<code>$1</code>")
    .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
    .replace(/\*([^*]+)\*/g, "<em>$1</em>")
    .replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
}

function markdown(src) {
  const out = [];
  let inList = false;
  for (const line of src.split("\n")) {
    const heading = line.match(/^(#{1,3}) (.*)/);
    const item = line.match(/^- (.*)/);
    if (item && !inList) { out.push("<ul>"); inList = true; }
    if (!item && inList) { out.push("</ul>"); inList = false; }
    if (heading) out.push(`<h${heading[1].length}>${inline(heading[2])}</h${heading[1].length}>`);
    else if (item) out.push(`  <li>${inline(item[1])}</li>`);
    else if (line.trim()) out.push(`<p>${inline(line)}</p>`);
  }
  if (inList) out.push("</ul>");
  return out.join("\n");
}

console.log(markdown(`# My notes
Learn **one** thing a day, *slowly*.
- Use \`const\` by default
- Read [MDN](https://developer.mozilla.org)
Never trust <script> tags from users.`));
```

**Output (logic run in Node.js 22)**

```text
$ node 08-markdown-preview.js
<h1>My notes</h1>
<p>Learn <strong>one</strong> thing a day, <em>slowly</em>.</p>
<ul>
  <li>Use <code>const</code> by default</li>
  <li>Read <a href="https://developer.mozilla.org">MDN</a></li>
</ul>
<p>Never trust &lt;script&gt; tags from users.</p>
```

**In the browser:** a text area on the left and a live preview on the right, updated on every keystroke.

**Stretch goal:** add numbered lists and code blocks, then compare your output with a real Markdown library.

### 13. Habit tracker with streaks

Turns dates into whole day numbers, removes the duplicate tick on 14 November with a `Set`, and finds the current and longest streak. The current streak survives until the end of tomorrow, which is why it is 3 on 15 November and 0 on 20 November.

```javascript
// Habit tracker: current streak and longest streak from a list of done-dates.
const DAY = 24 * 60 * 60 * 1000;
const toDay = (iso) => Math.round(Date.parse(iso + "T00:00:00Z") / DAY);   // whole days since 1970

function streaks(doneDates, todayIso) {
  const days = [...new Set(doneDates.map(toDay))].sort((a, b) => a - b);
  let longest = 0, run = 0;
  for (let i = 0; i < days.length; i++) {
    run = i > 0 && days[i] === days[i - 1] + 1 ? run + 1 : 1;
    longest = Math.max(longest, run);
  }
  // the current streak survives if the last tick was today or yesterday
  const today = toDay(todayIso);
  const last = days[days.length - 1];
  const current = last === today || last === today - 1 ? run : 0;
  return { current, longest, totalDays: days.length };
}

const log = ["2026-11-01", "2026-11-02", "2026-11-03", "2026-11-04", "2026-11-07",
             "2026-11-12", "2026-11-13", "2026-11-14", "2026-11-14"];
console.log(streaks(log, "2026-11-15"));
console.log(streaks(log, "2026-11-20"));
```

**Output (logic run in Node.js 22)**

```text
$ node 09-habit-streak.js
{ current: 3, longest: 4, totalDays: 8 }
{ current: 0, longest: 4, totalDays: 8 }
```

**In the browser:** a calendar grid of the month; clicking a day toggles it and saves to `localStorage`.

**Stretch goal:** track several habits and show a heat map of the past year.

### 14. Search as you type (debounce)

If a search box calls an API on every key press, typing "java" sends four requests. A debounce waits until typing pauses for 300 ms, so only the final word is searched. Our simulation types four keys 100 ms apart, pauses, then types again: two searches instead of five. The millisecond figures are rounded and can vary slightly between runs.

```javascript
// Debounce: wait until the user stops typing before calling the search API.
function debounce(fn, ms) {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(...args), ms);
  };
}

const start = Date.now();
const search = debounce((q) => console.log(`search("${q}") at ~${Math.round((Date.now() - start) / 100) * 100} ms`), 300);

// simulate keystrokes: "j", "ja", "jav", "java" typed 100 ms apart, then a pause, then "javas"
["j", "ja", "jav", "java"].forEach((q, i) => setTimeout(() => search(q), i * 100));
setTimeout(() => search("javas"), 1000);
```

**Output (logic run in Node.js 22)**

```text
$ node 10-debounce-search.js
search("java") at ~600 ms
search("javas") at ~1300 ms
```

**In the browser:** attach the debounced function to a search box's `input` event and fetch results from a public API.

**Stretch goal:** cancel an old request with `AbortController` if a newer one starts.

### 15 to 18. More intermediate ideas

- **GitHub profile finder:** type a username, `fetch` the public GitHub API, show the avatar and repositories, and handle "user not found" politely.
- **Flashcards with spaced repetition:** cards you get right move to a box you see less often; save the boxes in `localStorage`.
- **Budget planner with charts:** add income and expenses by category, total with `reduce`, and draw a chart with a library such as Chart.js.
- **Hangman with on-screen keyboard:** one click listener on the keyboard container (event delegation) instead of 26.

## JavaScript portfolio projects

A portfolio project should be finished, deployed (GitHub Pages or Netlify are free for static sites) and explained in a README. Games are excellent here because anyone can try them in ten seconds.

### 19. 2048 game

The whole game rests on one function: slide a row left and merge equal neighbours, each tile merging only once per move. That is why `[2,2,2,2]` becomes `[4,4,0,0]` and not `[8,0,0,0]`. The other three directions reuse it by reversing or rotating the board.

```javascript
// The heart of 2048: slide one row to the left and merge equal neighbours once.
function slideRow(row) {
  const tiles = row.filter((n) => n !== 0);
  const out = [];
  let gained = 0;
  for (let i = 0; i < tiles.length; i++) {
    if (tiles[i] === tiles[i + 1]) {
      out.push(tiles[i] * 2);
      gained += tiles[i] * 2;
      i++;                                   // skip the tile we just merged
    } else {
      out.push(tiles[i]);
    }
  }
  while (out.length < row.length) out.push(0);
  return { row: out, gained };
}

// the other three directions reuse slideRow by flipping or rotating the board
const slideRight = (row) => { const r = slideRow([...row].reverse()); return { row: r.row.reverse(), gained: r.gained }; };

for (const row of [[2, 2, 2, 2], [2, 0, 2, 4], [4, 4, 8, 8], [2, 4, 8, 16], [0, 0, 0, 2]]) {
  console.log(JSON.stringify(row), "left ->", JSON.stringify(slideRow(row).row), "score +" + slideRow(row).gained);
}
console.log("[2,2,2,0] right ->", JSON.stringify(slideRight([2, 2, 2, 0]).row));
```

**Output (logic run in Node.js 22)**

```text
$ node 11-2048-merge.js
[2,2,2,2] left -> [4,4,0,0] score +8
[2,0,2,4] left -> [4,4,0,0] score +4
[4,4,8,8] left -> [8,16,0,0] score +24
[2,4,8,16] left -> [2,4,8,16] score +0
[0,0,0,2] left -> [2,0,0,0] score +0
[2,2,2,0] right -> [0,0,2,4]
```

**In the browser:** a 4 by 4 grid, arrow keys and swipe gestures, a new tile after each move, and CSS transitions for the slide.

**Stretch goal:** detect game over (no empty squares and no equal neighbours), and add undo.

### 20. Minesweeper

Two pieces of logic: count the mines around every square, then flood-reveal when an empty square is clicked. The recursion opens a zero's neighbours, and any neighbour that is also zero keeps going, which is how one click opened 12 squares.

```javascript
// Minesweeper: neighbour counts, then the flood reveal when you click an empty square.
function buildBoard(rows, cols, mines) {
  const board = Array.from({ length: rows }, () => Array(cols).fill(0));
  for (const [r, c] of mines) board[r][c] = "*";
  for (const [r, c] of mines) {
    for (let dr = -1; dr <= 1; dr++) for (let dc = -1; dc <= 1; dc++) {
      const nr = r + dr, nc = c + dc;
      if (board[nr] && typeof board[nr][nc] === "number") board[nr][nc]++;
    }
  }
  return board;
}

function reveal(board, r, c, open = new Set()) {
  const key = r + "," + c;
  if (!board[r] || board[r][c] === undefined || open.has(key) || board[r][c] === "*") return open;
  open.add(key);
  if (board[r][c] === 0) {                    // empty square: open all eight neighbours too
    for (let dr = -1; dr <= 1; dr++) for (let dc = -1; dc <= 1; dc++) reveal(board, r + dr, c + dc, open);
  }
  return open;
}

const board = buildBoard(5, 6, [[0, 4], [1, 1], [3, 5], [4, 1]]);
console.log("Full board:");
board.forEach((row) => console.log("  " + row.join(" ")));
const open = reveal(board, 2, 3);
console.log(`Click (2,3) opens ${open.size} squares:`);
board.forEach((row, r) => console.log("  " + row.map((v, c) => (open.has(r + "," + c) ? v : "#")).join(" ")));
```

**Output (logic run in Node.js 22)**

```text
$ node 12-minesweeper.js
Full board:
  1 1 1 1 * 1
  1 * 1 1 1 1
  1 1 1 0 1 1
  1 1 1 0 1 *
  1 * 1 0 1 1
Click (2,3) opens 12 squares:
  # # # # # #
  # # 1 1 1 #
  # # 1 0 1 #
  # # 1 0 1 #
  # # 1 0 1 #
```

**In the browser:** a grid of buttons; left click reveals, right click flags (prevent the browser menu with `contextmenu`).

**Stretch goal:** make the first click always safe by placing mines after it.

### 21 to 25. More portfolio ideas

- **Snake on a canvas:** a game loop with `requestAnimationFrame`, the snake as an array of points, and collision checks.
- **Sorting algorithm visualiser:** write bubble, insertion and merge sort as generator functions that `yield` after each swap, and draw each step as bars.
- **Pathfinding visualiser:** draw walls on a grid and watch breadth-first search and A* find a route.
- **Real-time chat app:** a Node.js server with WebSockets, rooms, and messages broadcast to everyone in a room.
- **Browser extension:** a tab saver or a focus timer that blocks chosen sites; small, useful and impressive.

## JavaScript project ideas for kids and teens

Children from about 10 enjoy the rock paper scissors game, the dice roller, the random name picker and the age calculator, because they see the result at once. Our [JavaScript for kids](/javascript-for-kids) page shows where to start. Teens who want the page-building side as well should pair this list with our [HTML, CSS and JavaScript project ideas](/blog/html-css-javascript-project-ideas), and anyone heading for React should read [the JavaScript to learn before React](/blog/javascript-to-learn-before-react).

## How we teach it

On our [how we teach](/how-we-teach) page, students explain their thinking out loud, trace a loop line by line before running it, derive the rule themselves before they ever see it written down, and solve the same problem three ways. The Wordle scoring above is a good example: students usually find the repeated-letter bug themselves when they trace *apple* against *paper* by hand. Mistakes are data, not failures. Teens can learn this in [JavaScript for teens](/courses/javascript-course-for-teens-beginners-interactive-web), younger children in [web development for kids](/courses/kids-ai-web-development-course), and college students and adults in the [full stack developer course](/courses/full-stack-web-development-masterclass-college). The first class is free: [book a free demo class](/book-demo).

## Frequently asked questions

**What are good JavaScript project ideas for beginners?**

A tip and bill splitter, a live word counter, a palindrome checker, rock paper scissors, an age calculator, a random name picker, a unit converter, a dice roller, a Pomodoro timer and a typing speed test. Each has simple logic and an instant visible result.

**What JavaScript projects should an intermediate learner build?**

A Wordle clone, a Markdown previewer, a habit tracker with streaks, search as you type with debounce, a GitHub profile finder using fetch, flashcards with spaced repetition and a budget planner with charts.

**Which JavaScript projects are best for a portfolio?**

Finished, deployed projects that anyone can try quickly: 2048, Minesweeper, Snake, a sorting or pathfinding visualiser, a real-time chat app or a browser extension. Include a README and be ready to explain the hardest function.

**Can I test JavaScript project logic without a browser?**

Yes. Write the logic as plain functions that do not use document or window, and run them with Node.js or in the browser console. That is how the 12 tested projects on this page were checked.

**How is this different from HTML, CSS and JavaScript project ideas?**

Our HTML, CSS and JavaScript post focuses on building pages: layouts, forms and the DOM. This list focuses on the logic behind each app and shows that logic tested, with notes on how to wire it to a page.

**Do I need a framework like React for these projects?**

No. Every project here works with plain JavaScript. Building a few without a framework first makes React much easier to learn later.

**How long does a beginner JavaScript project take?**

The beginner projects take one to three hours including the page. Intermediate projects take a few evenings, and a polished portfolio game can take two weeks.

**Where can I host my JavaScript projects for free?**

Static projects can go on GitHub Pages or Netlify's free plan. The chat app needs a server, so it needs a host that runs Node.js.

[Book a free JavaScript class](/book-demo)

---

*Source: https://learn.modernagecoders.com/blog/javascript-project-ideas-for-beginners/*
