Giving Functions Information
Pass values in with parameters.
Giving Functions Information is a free Javascript for Kids lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Javascript for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Spells That Listen 👂
What if a spell could say hello to your name? 😲
We can give a spell information! That information is called a parameter. 🎁
A Gift Box 🎁
A parameter is like a gift box you hand to the spell.
The spell opens it and uses what is inside. 📦✨
Adding a Box 📥
We put a word inside the (). That word is the box. Let us call it name.
function greet(name) {
console.log("Hello, " + name + "!");
}
greet("Lily");Fill the Box! ✍️
When we cast greet("Lily"), we put "Lily" in the box. 🎁
The spell says: "Hello, Lily!" 👋
Try Your Name! 😄
Change "Lily" to YOUR name and run it! 🟢
function greet(name) {
console.log("Hello, " + name + "!");
}
greet("Sam");Same Spell, Many Gifts 🎊
One spell can greet lots of friends! Just give it different gifts. 🎁🎁🎁
function greet(name) {
console.log("Hi, " + name + "!");
}
greet("Max");
greet("Mia");
greet("Leo");Two Boxes! 📦📦
A spell can take more than one gift. Just use a comma between them.
function addPets(cats, dogs) {
console.log("You have " + (cats + dogs) + " pets!");
}
addPets(2, 3);Numbers as Gifts 🔢
Gifts can be words OR numbers! The spell uses whatever you hand it. 🎁
function double(num) {
console.log(num + num);
}
double(5);The Box Is Empty Until... 🫥
Inside the spell, name is empty until you cast it.
When you cast greet("Bo"), the box fills with "Bo"! 🎁
Why Boxes Are Magic ✨
Parameters make spells flexible! One spell works for everyone. 🌍
That is super powerful magic. 💪
You Gave a Gift! 🎁
Great job! You taught a spell to listen using parameters. 🎉
Spells are way more fun when they listen to you!
Quick Check 🧠
Question time! 🎯
Gift-Giving Wizard! 🏆
Awesome! Now your spells can take gifts and use them. 🎁✨
Next, we make spells give answers BACK. Cool! 🚀
Frequently asked questions
Is the “Giving Functions Information” lesson free?
Yes — the full text of “Giving Functions Information” is free to read here on the web, and the Javascript for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Javascript for Kids course, upgrade to CoddyKit PRO.
What will I learn in “Giving Functions Information”?
Pass values in with parameters. You practise Javascript for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Javascript for Kids?
No prior experience is required. Javascript for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Giving Functions Information” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Javascript for Kids lesson?
Yes. Every Javascript for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What Is a Function?
- Making Your First Function
- Giving Functions Information
- Getting Answers Back