🧪 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.
Leave a Reply