Skip to content
Clairos Learn

JavaScript basics · Lesson 10 of 12 · 7 minutes

JavaScript basics: Function parameters

Parameters let the same function work with different inputs without duplicating its body.

Mastery 0/3Run itExplain itApply it
Web workshopInert preview · code inspection

Current edit

PreviewNo external resources

Understand the pattern

Parameters let the same function work with different inputs without duplicating its body.

Parameters let the same function work with different inputs without duplicating its body.

Misconceptions to reject

  • A string containing code executes automatically when it is assigned.
  • A successful element lookup guarantees that the rest of an event handler is correct.

This is a code-inspection lab, not a full JavaScript runtime.

Worked example and expected result
function label(name) { return "Lesson: " + name; }
const paths = label("Paths");
const logs = label("Logs");

Parameters let the same function work with different inputs without duplicating its body.

Try a variation

Adapt the final example to a different project name while retaining its structure and relationships. A different context still needs a real browser and accessibility check.

Explain it

Which statement correctly explains function parameters?

Apply it elsewhere

You reuse function parameters in a different project. What must still be verified?

Keep the momentum.

Complete the lab, then explain and apply the pattern.

Next: JavaScript basics: Return valuesTry an incident drill

Anonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.

Keep learning

  1. 01JavaScript basics: Named functionsA named function groups a reusable operation; calling it runs its body.Practice
  2. 02JavaScript basics: Return valuesreturn supplies a result to the caller. A function without an executed return yields undefined.Practice
  3. 03JavaScript basics: Template stringsBacktick template strings can interpolate expressions with ${...}; ordinary quoted strings do not interpolate them.Practice