Making Your First Function
Write and call your own function.
Making Your First Function is a free Javascript for Kids lesson on CoddyKit — lesson 2 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.
Time to Make Magic! 🪄
Today YOU make your first spell! 🎉
We will build a spell called greet that says hello.
Start With the Magic Word 🔑
Every spell starts with function. 🐉
Then we add a name and some curly braces. Like building a sandwich! 🥪
Give It a Name 🏷️
Our spell name is greet. It means "say hello". 👋
We add () after the name. Those will be useful later!
Open the Treasure Chest 🧰
The { } hold the magic. Inside, we put what the spell should do.
function greet() {
console.log("Hello!");
}But Nothing Happened? 🤔
If you run that, nothing shows. 😮 That is because we only made the spell.
We did not cast it yet!
Cast Your Spell! ✨
To cast it, write the name with (). Watch the magic appear! 🟢
function greet() {
console.log("Hello!");
}
greet();Add More Magic ➕
You can put many lines inside the chest. They all happen when you cast! 🎆
function greet() {
console.log("Hello!");
console.log("Welcome, friend!");
}
greet();Cast It Again! 🔁
Cast your spell as many times as you like! 🎉
function greet() {
console.log("Hi there!");
}
greet();
greet();Make Your Own Spell 🌟
Try a spell called cheer. Make it shout something happy! 📣
function cheer() {
console.log("You are awesome!");
}
cheer();Spells Need the Curly Chest 🧰
Always remember: { } hold the magic, and () cast the spell.
No chest, no magic! 🚫🪄
Look What You Built! 🏗️
You made a real function and cast it! That is true coding wizardry. 🧙
Be proud of yourself! 🥳
Quick Check 🧠
Let us see what you remember! 🎯
Spell Master! 🏆
Yay! You can make and cast your own spells now. 🎉
Next, we teach spells to listen to YOU. So exciting! 🚀
Frequently asked questions
Is the “Making Your First Function” lesson free?
Yes — the full text of “Making Your First Function” 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 “Making Your First Function”?
Write and call your own function. 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 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Making Your First Function” 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