JS Exercises
Each JavaScript lesson page has an "Exercise" block — a tiny fill-in-the-blank with one or two missing tokens. You complete the code, click Check answers, and the page tells you if you got it right.
How it works
- The code template has
____markers where the answer goes. - Type the missing token into each blank.
- Press Check answers — correct fields turn green, wrong ones red.
- Show hint uncovers a clue if you're stuck.
- Many blanks accept multiple equivalent answers (e.g.
constorletwhere both work).
Example shape
Instruction
Use the modern method to attach a click handler.
Template (a blank is shown as ____)
btn.____('click', onClick);
Why the exercises matter
| Skill the exercises build | How |
|---|---|
| Spelling tricky APIs | addEventListener, querySelectorAll, setProperty — easy to half-remember. |
| Recognising idioms | Object.fromEntries, Promise.all, arr.filter(Boolean) — the patterns repeat. |
| Sharpening reading speed | Fill-the-blank forces you to slow down and parse. |
Tip: Doing the exercise on every lesson — even quick ones — compounds. By topic 50 you'll find you write JavaScript without consulting the docs.
Example
Example
<!DOCTYPE html>
<html>
<body>
<p id="out"></p>
<script>
document.getElementById("out").textContent = "Hello from JS Exercises!";
</script>
</body>
</html>
Try it Yourself »
Exercise
What four characters mark a blank?
Answer:
Same character repeated four times.
Discussion
Loading…