Learning new English words only works if you see them more than once — and a small app you build yourself is a good way to make that happen. In this tutorial, we will build a Vocabulary Builder: it shows you a random word with its meaning, lets you add your own words, and quizzes you on the ones you have saved.
If you are learning English alongside this, it helps to have a good book list to work from — this best English speaking books for beginners guide picks the right book for each level, so you can take the words from the books you are actually reading and add them to the app.
Let us start with the HTML. We need a word display, a button for a new word, a form to add words, and a small quiz area:
<div id="card">
<h2 id="word">Serendipity</h2>
<p id="meaning">Finding something good without looking for it.</p>
<button id="newWord">New Word</button>
</div>
<form id="addForm">
<input id="newWordInput" placeholder="Word" required>
<input id="newMeaningInput" placeholder="Meaning" required>
<button>Add Word</button>
</form>
<p id="score">Quiz score: 0</p>
<button id="quizBtn">Quiz Me</button>
<p id="quizQuestion"></p>
Now the JavaScript. We keep the words in an array, save them to localStorage so they survive a refresh, and pick a random word to display:
const defaultWords = [
{ word: 'Serendipity', meaning: 'Finding something good without looking for it.' },
{ word: 'Resilient', meaning: 'Able to recover quickly from difficulties.' },
{ word: 'Eloquent', meaning: 'Fluent and persuasive in speech.' },
{ word: 'Pragmatic', meaning: 'Practical rather than idealistic.' },
{ word: 'Meticulous', meaning: 'Showing great attention to detail.' }
];
let words = JSON.parse(localStorage.getItem('vocabWords')) || defaultWords;
let score = 0;
const wordEl = document.getElementById('word');
const meaningEl = document.getElementById('meaning');
function showRandomWord() {
const entry = words[Math.floor(Math.random() * words.length)];
wordEl.textContent = entry.word;
meaningEl.textContent = entry.meaning;
}
document.getElementById('newWord').addEventListener('click', showRandomWord);
document.getElementById('addForm').addEventListener('submit', (e) => {
e.preventDefault();
const word = document.getElementById('newWordInput').value.trim();
const meaning = document.getElementById('newMeaningInput').value.trim();
if (!word || !meaning) return;
words.push({ word, meaning });
localStorage.setItem('vocabWords', JSON.stringify(words));
e.target.reset();
showRandomWord();
});
document.getElementById('quizBtn').addEventListener('click', () => {
const entry = words[Math.floor(Math.random() * words.length)];
const answer = prompt(`What does "${entry.word}" mean?`);
if (answer && answer.trim().toLowerCase() === entry.meaning.toLowerCase()) {
score++;
alert('Correct!');
} else {
alert(`Not quite. It means: ${entry.meaning}`);
}
document.getElementById('score').textContent = `Quiz score: ${score}`;
});
showRandomWord();
How it works: showRandomWord picks a random entry and updates the card. The add form pushes a new word into the array and saves the whole list to localStorage. The quiz picks a random word and checks your answer against the stored meaning — a simple string comparison, so it is forgiving to build on later.
A few ideas to extend it: add a "hide meaning" toggle so you guess before revealing, track which words you get wrong and show those more often, or add example sentences for each word. Each of those is a small feature on its own, and each one teaches you something new about state and the DOM.
Top comments (0)