A simple Animal remake is a good vanilla JavaScript project because the rules are clear and the data structure is small. You do not need a server, a database or a framework unless you want shared online brains.
The browser version on this site uses three main ingredients: a tree object, a mode-based input loop, and local browser storage.
1. Represent the brain as a tree
const brain = {
type: 'question',
text: 'Does it swim?',
yes: { type: 'animal', text: 'fish' },
no: { type: 'animal', text: 'bird' }
};
Question nodes have yes and no branches. Animal nodes are leaves.
2. Walk through the tree
When the current node is a question, ask it and follow the branch matching the user’s answer. When the current node is an animal, make a guess.
if (node.type === 'question') {
node = answer === 'yes' ? node.yes : node.no;
} else {
guess(node.text);
}
3. Replace a wrong guess with a new question
When the program guesses incorrectly, keep the old animal, ask for the new animal, ask for a distinguishing question, and then replace the old animal node with a question node.
currentNode.type = 'question'; currentNode.text = newQuestion; currentNode.yes = newAnimalNode; currentNode.no = oldAnimalNode;
4. Save locally
For a static site, localStorage is enough:
localStorage.setItem('animalBrain', JSON.stringify(brain));
const saved = JSON.parse(localStorage.getItem('animalBrain'));
That saves the learned brain in this browser. Export/import buttons can turn that same JSON into a user-controlled save file.
What to avoid at first
Do not start by building a full BASIC interpreter, a ZX81 emulator or a multi-user shared brain. The appeal of Animal is that the core idea is visible, so a first version should stay small, explainable and self-contained.