Getting Answers Back
Return results from a function.
Getting Answers Back is a free Javascript for Kids lesson on CoddyKit — lesson 4 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 Answer 💬
Some spells do not just speak. They hand you an answer back! 🎁
The magic word for this is return. ↩️
Like Asking a Wizard 🧙
Imagine asking a wizard: "What is 2 + 2?"
The wizard thinks, then hands you the answer: 4! 🪄
The return Word ↩️
return means "here is your answer, take it!" 🎁
function addUp(a, b) {
return a + b;
}
console.log(addUp(2, 2));Catch the Answer 🥎
The spell addUp gives back 4. We catch it and print it! 🎉
Run it and see the 4 appear.
Save the Answer 📥
We can save the answer in a box to use later. 📦
function addUp(a, b) {
return a + b;
}
let total = addUp(10, 5);
console.log("Total is " + total);return Stops the Spell 🛑
When return happens, the spell stops right there.
It hands back the answer and is done! ✅
function check() {
return "Done!";
console.log("This never runs");
}
console.log(check());Speak vs Give 🗣️🎁
console.log just speaks out loud. 🗣️
return actually gives you the answer to keep. 🎁
Use the Answer Again ♻️
Because return gives an answer, you can use it in more math! 🧮
function triple(n) {
return n * 3;
}
console.log(triple(2) + triple(4));A Spell Inside a Spell 🪆
You can even put one spell answer inside another! Like nesting dolls. 🪆
function add(a, b) {
return a + b;
}
console.log(add(add(1, 2), 3));Why return Is Mighty 💪
With return, spells can work together. One gives an answer, another uses it! 🤝
That is how big magic gets built. 🏰
You Got Answers! 🎉
Wonderful! Now your spells can hand you answers with return. ↩️
You are becoming a real coder! 🧙
Quick Check 🧠
Last question for this spell-book! 🎯
Function Champion! 🏆
Hooray! You finished all about functions! 🎊
You can make spells, give them gifts, and get answers back. Amazing! 🚀
Frequently asked questions
Is the “Getting Answers Back” lesson free?
Yes — the full text of “Getting Answers Back” 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 “Getting Answers Back”?
Return results from a 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 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Getting Answers Back” 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