James McGrath

Quick tips, in-depth guides, and thoughts on the future of the web

What Is a Return Statement?

🧪 Concept:

A return statement sends a value back from a function. Instead of just doing something, the function gives you something back — like a vending machine for code.

function add(a, b) {
return a + b;
}

let sum = add(3, 4);
console.log(sum); // 7

Here, the function adds the numbers and returns the result. You can store that result, use it in other code, or pass it to something else.

🧰 Why It Matters:

Returning values lets your functions do more than just print things — they can calculate, combine, transform, and share results with the rest of your program.

🎉 Quick Challenge:

Write a function that returns your favorite emoji:

function getEmoji() {
return "🌈";
}

console.log(getEmoji()); // 🌈

🧠 Fun Analogy:

A return statement is like a reply in a conversation. You ask a function for something — and it talks back.

📚 Further Reading:

MDN Docs – return
W3Schools – JavaScript Return Statement

Subscribe to my feed to follow along. I’ll keep the lessons short and sweet.

What Is a Function Parameter?

One response to “What Is a Return Statement?”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.