What Is a Function?
🧪 Concept:
A function is like a recipe. You write it once and then reuse it to get the same result — or tweak it to serve different ingredients.
In code, it might look like this:
function sayHello() {
console.log("Hello, world!");
}You just:
▪ Declared a function named sayHello
▪ Told it to log a message when called
To use it, just call it:
sayHello();🧰 Why It Matters:
Functions keep your code clean, reusable, and organized. Instead of repeating yourself, you define it once and use it whenever you need it.
🎉 Quick Challenge:
Write a function that says something about you! Like:
function aboutMe() {
console.log("I love coffee and coding!");
}Call it and see the magic happen.
🧠 Fun Analogy:
A function is your own custom button. Press it, and something happens. It could make toast, launch fireworks, or just say hi — you choose.
📚 Further Reading:
▪ MDN Docs – Functions
▪ W3Schools – JavaScript Functions
Subscribe to my feed to follow along. I’ll keep the lessons short and sweet.
Leave a Reply