>_BeginnerCoder
Donate

Lesson 4 — Functions

Functions

A function groups reusable code under a name. The modern arrow form, const double = (n) => n * 2, is short and everywhere in JavaScript.

Why it matters: functions are the core building block of every JS app — you will pass them around, reuse them and combine them constantly.

Tip: an arrow function with no braces returns its expression automatically; add braces and you must write return yourself.

Task

Write double(n) returning n*2, then log double(7).

← Back
Next →

Enjoying this lesson? Share it 👇

Keep going with JavaScript Foundations

Ready for more? These paid resources pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. We only recommend tools we believe are genuinely useful.