Skip to content
Tutorials Center
My learning

Topics

Lesson 45 of 50 · Projects and Practice

Project 1: Build a Spaced-Repetition Flashcard Trainer

Build a Leitner-box flashcard trainer for Italian vocabulary: learn how spaced repetition works, simulate review days in code and try a working trainer.

Vocabulary is the fuel of a language, and forgetting is the main enemy. Psychologists have known since the nineteenth century that memories fade quickly unless they are refreshed at the right moments. A simple method called spaced repetition exploits this: you review new words often and well-known words rarely. In this project you will build a small flashcard trainer in JavaScript that works this way, and you will use it to learn the vocabulary of the first eight chapters.

The system you will build is the Leitner box method, invented by the German science journalist Sebastian Leitner in the 1970s. It needs no complex mathematics, only a handful of boxes and a few rules, which makes it perfect for a first coding project and for real study.

Five numbered Leitner boxes with arrows: correct answers move a card to the next box, wrong answers send it back to box 1, with review intervals of 1, 2, 4, 8 and 16 days
The Leitner system: a correct answer moves a card one box forward, a wrong answer sends it back to box 1.

What you will learn

  • How spaced repetition works and why it beats cramming.
  • How to model flashcards and boxes as simple data.
  • How to simulate several days of study in code.
  • How to adapt the trainer to your own vocabulary.

Key terms

Ripasso (review): going over material you have already seen.

Ripetizione dilazionata (spaced repetition): reviewing at increasing intervals.

Scatola (box): in the Leitner system, a stage where a card waits until its next review.

Scheda: a flashcard; the word is also used for a form or a file card.

How the Leitner method works

Imagine five boxes numbered 1 to 5. Every card starts in box 1. Each box has a review interval:

Box Review every Meaning
1 day new or forgotten cards
2 2 days seen once correctly
3 4 days getting familiar
4 8 days known well
5 16 days nearly permanent

The rules are simple:

  1. On a given day, review all the cards in the boxes that are due.
  2. If you answer a card correctly, move it to the next box (up to box 5).
  3. If you answer wrongly, put it back in box 1.

Easy cards quickly climb to box 5 and appear rarely, while difficult cards keep returning to box 1 until they stick. The result is that you spend your time on the words you actually find hard.

Note that the exact intervals are a design choice. Researchers have studied many schedules, and the best interval depends on the learner and the material. Treat the table as a sensible default, and adjust it if you forget too much or find the reviews too easy.

Step 1: model the cards

A card needs an Italian side, an English side and a box number. In JavaScript we can use plain objects:

JavaScript
{ it: "il binario", en: "the platform", box: 1 }

Our vocabulary comes from the previous chapters: question words, food and travel. Keep the Italian with its article, because a noun and its gender should be learned together (il binario, la stazione), a habit that will make agreement much easier later.

Step 2: decide what is due

Each box has an interval in days. We simulate time with a day counter. A card is due on day d if d is a multiple of its box interval. That is not how a calendar application would do it (it would store a "next review" date), but it is simple and works for a demonstration.

JavaScript
const interval = { 1: 1, 2: 2, 3: 4, 4: 8, 5: 16 };
const isDue = (card, day) => day % interval[card.box] === 0;

Step 3: the answer rule

When you answer, update the box:

JavaScript
function review(card, correct) {
  card.box = correct ? Math.min(card.box + 1, 5) : 1;
}

Step 4: simulate study days

In the first TryIt below we run a simulation. The student is a simulated learner: each card has a fixed chance of being remembered, which is higher for easy words. We simulate 16 days and print where each card ends up. This is a model, not real learning data, but it shows how cards separate into "easy" and "hard".

JS Leitner simulation

Press Run (or Ctrl + Enter) to see the console output here.

No output.

You will see that the total number of reviews per day falls as cards climb the boxes. This is the point of spaced repetition: the effort drops as your knowledge grows.

Step 5: a working trainer

The second TryIt is a complete, interactive trainer. It keeps the same five boxes but lets you play: it shows the Italian word, you type the English meaning (or think of it), reveal the answer and mark yourself right or wrong. Your progress lives only in the page, because this preview cannot save data between visits. For real study, copy the code into a local file and add saving with localStorage.

Interactive Leitner trainer

Step 6: extend the project

Here are ideas for taking the trainer further:

  • Add saving. Store the cards array in localStorage after every answer and load it on startup (this needs a real web page, not the sandboxed preview).
  • Add direction switching. Show English and ask for the Italian, which trains recall instead of recognition.
  • Add typing. Instead of self-marking, check a typed answer and tolerate accents with the technique from the drills in this chapter.
  • Add dates. Replace the day counter by a nextReview date saved on each card.
  • Add your own words. Use the glossary lesson as a starting deck.

Why spaced repetition works, honestly

Memory research has repeatedly found that retrieving a word just as you are about to forget it strengthens the memory more than reading it again right away. This is sometimes called the testing effect or desirable difficulty. Spaced schedules take advantage of it, and many studies show better retention than cramming. At the same time, the exact numbers (1, 2, 4, 8, 16 days) are a convention and not a law of nature, and individual differences are large. If you find the reviews too hard, shorten the intervals; if they are too easy, lengthen them.

How to use the trainer for each chapter

Make a separate deck for each chapter and aim for ten to fifteen cards per day, not more. Choose words you really want to use, and put a short example sentence on the back (il binario: Il treno parte dal binario due). Review every day, even for five minutes. Add new cards only when the number of cards due falls below twenty; otherwise the pile grows faster than you can review it. When a card is stuck in box 1 for a week, rewrite it: add an image, a different sentence, or a memory hook.

Common misconceptions

"More reviews are always better." Reviewing a known word too often wastes time. The spacing is the point.

"Flashcards replace conversation." Cards build vocabulary, but you still need to use words in sentences and with people.

"I should learn words without articles." For Italian nouns, learn the article with the noun (il binario, la stazione), because it carries the gender.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. In the Leitner system, what happens when you answer a card wrongly?

    A wrong answer returns the card to box 1 so you see it again soon.
  2. 2. How often do you review the cards in box 3 in our table?

    Box 3 has a 4-day interval in the default schedule.
  3. 3. Why is spaced repetition efficient?

    It adapts the effort to what you find hard, cutting wasted reviews.
  4. 4. Why should nouns be learned with their article?

    The article (il, la, lo) reveals the gender, which you need for adjectives and pronouns.

Summary

  • Spaced repetition reviews new words often and known words rarely.
  • The Leitner method uses boxes: correct answers move up, wrong ones return to box 1.
  • A small JavaScript model (cards, boxes, intervals) simulates study and drives a trainer.
  • Learn nouns with their articles and extend the trainer with saving, typing and your own words.

Next: Project 2: a verb conjugator