Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 36 ยท Projects and Practice

Project: A Flashcard Quiz Engine

Build a small flashcard quiz engine in JavaScript with Leitner boxes: add cards, run a quiz round, move cards between boxes and view your progress.

Now you will build a tiny flashcard engine that applies the Leitner system from the lesson on active recall and flashcards. It is a stand-in for a flashcard app: it runs in the console, uses simulated answers, and shows how the rules work. In real use you would answer from memory.

We will build it in three steps, adding features each time.

Step 1: Represent cards and boxes

Each card has a question, an answer and a box number. All new cards start in box 1.

JS Step 1: the card deck

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

No output.

A deck is just an array of objects. Each object can be updated as you review.

Step 2: One review round

The rules:

  • A correct answer moves a card up one box, to a maximum of box 4.
  • A wrong answer sends the card back to box 1.

To keep the example repeatable, we simulate the answers with a list of true or false. In a real app, you would compare the learner's typed answer with the card.

JS Step 2: review round with simulated answers

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

No output.

Notice how the wrong answer sends the second card from box 2 to box 1, while the right answers move up.

Step 3: Decide which cards are due today

In the Leitner system, lower boxes are reviewed more often. A simple schedule is: box 1 every day, box 2 every 2 days, box 3 every 4 days, box 4 every 8 days. We can then compute which boxes are due on a given day number.

flowchart TD
    A["Start of study day"] --> B["Which boxes are due today?"]
    B --> C["Collect those cards"]
    C --> D["Quiz each card"]
    D -->|correct| E["Move up one box"]
    D -->|wrong| F["Back to box 1"]

The daily loop of a Leitner flashcard session.

JS Step 3: due boxes by day

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

No output.

Box 1 shows up every day; box 4 only on day 8. This makes the workload manageable as cards move up.

Putting it together

Here is the whole engine in Python, using the same rules. It takes the invented answers for each day and prints the state of the boxes. A real version would read answers from the learner.

Python The engine in Python

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

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Read the output line by line and check the rules by hand. Does each card end up in the box you expect?

Ideas to extend it

  • Let the learner type answers and compare them, ignoring case and spaces.
  • Add a "hint" with the first letter.
  • Save the deck to a file.
  • Add statistics: percentage correct, cards per box.
  • Add tags so that you can quiz one topic at a time.

A good flashcard program is only half the story. The quality of the cards matters just as much: one idea per card, precise questions and answers in your own words.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. In this engine, what happens to a card answered wrongly?

    A wrong answer sends the card back to box 1 so it is reviewed often.
  2. 2. With intervals 1, 2, 4 and 8 days, how often is box 3 reviewed?

    Box 3 uses an interval of 4 days.
  3. 3. Why use a maximum box number?

    The top box is the longest interval; cards stay there until they are answered wrongly.

Summary

  • Represent cards as objects with a question, answer and box number.
  • Correct answers move a card up; wrong answers send it back to box 1.
  • Lower boxes are due more often, higher boxes less often.
  • This engine uses simulated answers; a real app reads the learner's answers.
  • Good cards matter as much as good code.

Next: Practice: Plan Your Exam Week