Skip to content
How to start
Menu
A beginner testing a small interactive web page on a laptop at a tidy desk

Indoor hobbies

How to start programming with one small working project

Cost to start
~$0

Computer, browser, free editor

Difficulty
Beginner

Keep the first project tiny

First result
1-2 hours

A button that updates a page

Build a tiny interactive web page, learn a calm debugging routine, and turn beginner lessons into your own projects without chasing every language.

What you need to know

  1. Choose an outcome before a language

    A tiny page, game or automation gives each new concept a job. The universally perfect first programming language does not exist.

  2. Use two small text files

    HTML supplies the button and result area. JavaScript changes the text when you click. Save both files together in a plain-text editor.

  3. Type, predict and change every example

    Before running a line, say what you expect. Then alter one value or condition and explain why the result changed.

  4. Treat errors as evidence

    Read the first console error, note its file and line, inspect the nearby code and test one hypothesis instead of rewriting everything.

  5. Keep private information out of code

    Never paste passwords, access tokens or personal data into a project, public repository, coding assistant or unfamiliar command.

Put a button on the page

Make a folder called first-page. In a plain-text editor, save the following as index.html inside it. Open the file in a browser. You should see a button and a short instruction.

<!doctype html>
<html lang="en">
  <meta charset="utf-8" />
  <title>What shall I draw?</title>
  <button id="choose">Pick a subject</button>
  <p id="result" aria-live="polite">Press the button for an idea.</p>
  <script src="script.js"></script>
</html>

Make the page respond

Save this second file as script.js in the same folder. The names after the hash signs match the two IDs in your HTML. Each click shows one subject and advances the index. The remainder operator (%) takes it back to zero after the last subject.

const subjects = ['a mug', 'a leaf', 'a shoe'];
const button = document.querySelector('#choose');
const result = document.querySelector('#result');
let index = 0;

button.addEventListener('click', () => {
  result.textContent = subjects[index];
  index = (index + 1) % subjects.length;
});

Refresh the page and click four times. The fourth click should show the mug again. Add one subject to the list, save and refresh. Predict which click will bring the mug back.

Build a calm debugging loop

When nothing happens, open the browser developer tools and select the Console. Read the first error before the cascade beneath it. The message usually names a file, line and error type. Check spelling, capitalization, quotes and brackets around that line.

Save your work and choose a direction

Make a copy of the folder after the first working version, or learn basic Git once you want a durable history. A version-control commit is a named checkpoint, not a cloud backup by magic.

Turn this into income