Day 9: Function Parameters & Return Values in JavaScript
What Are Parameters?

About Me Tech enthusiast and developing web developer with a growing passion for blockchain technology. My journey spans 3 years of HTML/CSS crafting, 2 years of JavaScript exploration, and recent ventures into React, Node.js, and the blockchain space. Currently at the beginning of my blockchain journey while building a solid foundation in web development technologies. Fascinated by the potential of decentralized systems and eager to contribute to this evolving ecosystem. Technical Background I bring a diverse technical toolkit that includes: Strong foundation in web fundamentals (HTML/CSS: 3 years) Dynamic front-end development with JavaScript (2 years) and React (1 year) Modern UI implementation using Tailwind CSS and Bootstrap (7 months) Server-side programming with Node.js (1 year) and Python (2-3 years) Early-stage blockchain development knowledge Beginning exploration of Rust programming (4 months) Blockchain Journey While still at the beginner level in blockchain technology, I'm actively learning about distributed ledger concepts, smart contract fundamentals, and the broader implications of Web3. My interest in this space stems from a belief in the transformative potential of decentralized technologies and their ability to reshape digital interactions. Vision & Goals My development path is guided by a clear progression: mastering web development fundamentals, expanding into blockchain applications, and ultimately exploring the intersection of these technologies with artificial intelligence. I see tremendous potential in combining these domains to create innovative solutions for tomorrow's challenges. Collaboration Interests Open to connecting with fellow developers, blockchain enthusiasts, and mentors who share an interest in the convergence of web development and emerging technologies. Particularly interested in learning opportunities, knowledge exchange, and potential collaboration on projects that push the boundaries of what's possible in the decentralized space. Current Focus Deepening my understanding of React and Node.js ecosystems while simultaneously building knowledge in blockchain fundamentals and smart contract development. Committed to continuous learning and practical application of new skills.
Parameters are variables listed inside the parentheses of a function definition. They act as placeholders for values you pass into the function.
Think of parameters like the delivery address for a package — the function needs to know where to send or use the data.
Example:
javascriptCopyEditfunction greet(name) {
console.log(`Hello, ${name}!`);
}
greet("God'sgift"); // Output: Hello, God'sgift!
greet("Samuel"); // Output: Hello, Samuel!
Here, name is a parameter and "God'sgift" or "Samuel" are arguments (the actual values you pass).
Multiple Parameters
A function can have more than one parameter, separated by commas.
Example:
javascriptCopyEditfunction add(a, b) {
console.log(a + b);
}
add(3, 4); // Output: 7
add(10, 5); // Output: 15
Return Values
So far, we’ve used console.log() to display results, but sometimes you want a function to give back a value you can use later.
This is where the return statement comes in.
Example:
javascriptCopyEditfunction multiply(a, b) {
return a * b;
}
let result = multiply(5, 6);
console.log(result); // Output: 30
The return statement sends the value back to the part of the code that called the function.
Important Notes on return
returnends the function immediately — no code after it will run.If no
returnis given, the function returnsundefinedby default.
Example:
javascriptCopyEditfunction test() {
return "Done!";
console.log("This will never run");
}
console.log(test()); // Output: Done!
Why Use Parameters & Returns?
They make functions reusable, dynamic, and powerful.
Instead of hardcoding values, you can pass any data you want into the same function.
Summary
Parameters are placeholders for function input.
Arguments are the actual values passed.
returnsends a value back from the function.Functions without
returngiveundefined.
📝 Practice Questions
Easy
Write a function square that takes a number as a parameter and returns its square.
Intermediate
Create a function calculateArea that takes length and width as parameters and returns the area of a rectangle.
Hard
Write a function isEven that takes a number and returns true if it’s even, and false if it’s odd. Then use this function to log all even numbers from 1 to 20.
💡 Tomorrow (Day 10), we’ll explore Default Parameters & Arrow Functions to make your code even more flexible.
#CodeWithGift #30DaysOfJavaScript #JavaScriptSeries






