← Home

What Is a Function Parameter?

· 1 min read

πŸ§ͺ Concept:

A parameter is a placeholder in a function β€” like a blank to fill in when you call it.

function greet(name) {
  console.log("Hello, " + name + "!");
}

greet("Riley");

This outputs: Hello, Riley!
You passed in "Riley" to fill the name blank.

🧰 Why It Matters:

Parameters make your functions flexible. One function can handle all kinds of input β€” just pass in what you need.

πŸŽ‰ Quick Challenge:

Write a function with a parameter for a favorite food:

function sayFavorite(food) {
  console.log("I love " + food + "!");
}

sayFavorite("ramen");

🧠 Fun Analogy:

A parameter is like a fill-in-the-blank in a greeting card. β€œDear ___” becomes anything you want.

πŸ“š Further Reading:

β–ͺ MDN Docs – Functions
β–ͺ W3Schools – JavaScript Function Parameters

Subscribe to my feed to follow along. One tip a day, no overwhelm.

What Is an If Statement?