BeginnerCoder

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.

Want it another way?
Task

Write double(n) returning n*2, so the last line logs 14.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.