
Introduction to Functions
Copying and pasting the same code over and over works for a while—until you need to change something and suddenly have to hunt through ten copies of the…
Read tutorialLearn how to organize code with functions and respond to user actions with events.
Tutorials
Follow these lessons in order, or jump directly to the topic you need.

Copying and pasting the same code over and over works for a while—until you need to change something and suddenly have to hunt through ten copies of the…
Read tutorial
A function that always does the same thing is a dead end. A function that can accept input and hand back a result becomes a tool you can reuse anywhere.
Read tutorial
JavaScript arrow functions let you write the same functions you already know in fewer lines. The idea isn't new—only the syntax is shorter.
Read tutorial
You built a button. It looks great. You click it, and... nothing. The page just sits there, politely ignoring you.
Read tutorial
You have a button on your page. You want something to happen when someone clicks it. That moment—when a static page starts responding—is where JavaScript…
Read tutorial
A button click is one quick signal. Typing is a stream of signals. Every search box, sign-up form, and chat input depends on JavaScript watching that…
Read tutorial
Reading about functions feels clear. Writing one from scratch feels different. That gap is normal—and it closes the same way for everyone: by running code,…
Read tutorial
You fill out a form, hit submit, and the whole page jumps. Everything you typed is gone. The browser did what forms do by default: it sent the data and…
Read tutorial
You built a list. You wired every item with a click listener. It worked. Then you added one new item, clicked it, and nothing happened. The old approach…
Read tutorial
You wrote the addEventListener line. You clicked the button. Nothing happened. No error message. No reaction. Just silence.
Read tutorial