📚 College Credit Guide ✓ UPI Study 🕐 7 min read

How Do JavaScript Function Arguments and Return Values Work?

This article explains how JavaScript functions take input, use it inside the code, and send results back with return values.

US
UPI Study Team Member
📅 August 23, 2026
📖 7 min read
US
About the Author
The UPI Study team works directly with students on credit transfer, degree planning, and course selection. We've helped thousands of students figure out what counts toward their degree and how to finish faster without paying more than they have to. This post is written the way we'd explain it to you directly.
🦉

JavaScript functions take input through arguments, use named parameters inside the function, and send results back with return values. That sounds small, but it drives almost every beginner coding task, from adding two numbers to building a form check in a 2026 web app. If you are taking an introduction to JavaScript course, this is one of the first ideas to get right. A function call passes values in. The function body reads those values, does some work, and may return a new value to the caller. Miss that last step, and your code can print something to the screen without giving you anything useful to store or reuse. A lot of new students mix up parameters and arguments on day 1. That mix-up causes real pain later, especially when a function has 2 or 3 inputs and one missing return breaks the whole result chain. The good news: the rule stays simple once you see it in plain code. Think of a function like a machine with 2 doors. One door takes values in. The other door sends a result out. If you keep those doors straight, handling arguments and return values in JavaScript functions concepts and illustrations starts to feel normal fast, not mysterious.

Focused view of a computer screen displaying programming code with visible reflections — UPI Study

How Do JavaScript Arguments Reach a Function?

A function gets arguments at the call site, and those values land in the parameters listed in the function definition. In a basic introduction to JavaScript course, you might write `greet("Mia")`, and the string `"Mia"` moves into the `name` parameter inside `function greet(name) { ... }`.

The catch: The function does not grab the value from nowhere; the caller sends it in on purpose, and JavaScript matches values by position, not by your hopes or your comments. If you call `add(2, 3)`, then `2` fills the first parameter and `3` fills the second, which matters a lot when a function needs 2 values and not 1.

That same rule helps in real beginner code. A course task might ask you to build a price label for a $25 item with a 10% tax rate, so you pass both numbers into one function and let the function do the math. Inside the body, the parameters act like local variables, which means the function can read them, combine them, and build a result without guessing.

Here is the shape of it:

`function total(price, taxRate) {` ` return price + price * taxRate;` `}`

`total(25, 0.1)` sends `25` and `0.1` into the function, and the body uses those 2 values to calculate `27.5`. That simple pattern sits at the heart of a lot of Introduction to JavaScript practice work, because students learn faster when they can see the caller and the function body as 2 sides of the same exchange.

One downside shows up fast: if you pass arguments in the wrong order, JavaScript still runs the code, but the math comes out wrong. That is why a function that expects `minutes` first and `rate` second can break a $15 billing example even when the syntax looks fine.

What Is the Difference Between Parameters and Arguments?

Parameters and arguments look almost the same on paper, and that trips people up in week 1. The clean split is simple: parameters live in the function definition, while arguments show up at the call site as the actual values. A small code example makes the difference stick much better than a long lecture.

What this means: You name the slots first, then you fill them later with real data like `"Ava"`, `12`, or `0.2`, and that order matters every single time.

Column 1Column 2Column 3
ParameterInside function definition`function sum(a, b)`
ArgumentAt the call site`sum(4, 9)`
Exists whenFunction is writtenFunction runs
Common mix-upCalling `a` an argument`a` is a parameter
Runtime valueNamed slotActual number or string
Example use`discount(price, rate)``discount(50, 0.15)`

A lot of students remember this by thinking of a school form: the form has blanks, and the student fills them in with real facts. Same idea, just with code. If you want a neat practice path, a JavaScript intro course gives you repeated reps with both words until they stop blurring together.

Introduction To Javascript UPI Study Course

Learn Introduction To Javascript Online for College Credit

This is one topic inside the full Introduction To Javascript course on UPI Study — a self-paced, online class that earns real college credit. Credits are ACE and NCCRS evaluated and transfer to partner colleges across the US and Canada. Courses start at $250 with no deadlines and lifetime access.

Explore on UPI Study →

How Do JavaScript Functions Use Passed Values?

Functions use passed values by reading the parameters like normal variables, then placing them inside expressions, strings, or condition checks. In a 2026 coding class, you might pass `3` and `5` into `multiply`, then use those values to produce `15` without touching anything outside the function.

Inside the body, you can add, subtract, join, compare, or format the values. That makes the function do real work instead of just sitting there. A function like `formatName(first, last)` can turn `"Nia"` and `"Patel"` into `"Nia Patel"`, and a function like `hoursToMinutes(hours)` can turn `2` into `120` for a scheduling app.

Reality check: If a function gets 3 inputs and one of them is missing, JavaScript will still run the call, but your output can become `NaN`, `undefined`, or a weird string you did not want.

Here is a tiny example:

`function ticketPrice(age, basePrice) {` ` return age < 18 ? basePrice * 0.8 : basePrice;` `}`

`ticketPrice(16, 20)` returns `16`, while `ticketPrice(22, 20)` returns `20`. That one line shows the whole idea: the function does not care where the values came from, only that the caller passed them in and the body used them correctly.

A lot of beginners like this part because it feels practical fast, and I agree. It beats memorizing rules in a vacuum.

Why Do JavaScript Return Values Matter?

Return values matter because they send usable data back to the caller, and that lets one function feed another. A function that returns `7` can store that number in a variable, pass it into another function, or show it in a page, while a function that only logs text gives you no reusable result.

`console.log()` prints for people. `return` gives data back to code. That difference sounds tiny, but it decides whether your function acts like a dead end or a useful step in a larger program. A `sum(2, 5)` function can return `7`, and then a second function can take that `7` and multiply it by `3` to get `21`.

Bottom line: A return value turns a function from a one-time action into a building block, and that is the whole reason 90% of beginner examples lean on it.

Compare these 2 cases:

`function sayHi(name) {` ` console.log("Hi, " + name);` `}`

`function getHi(name) {` ` return "Hi, " + name;` `}`

The first one prints `Hi, Sam` and stops. The second one gives back a string you can save in `message`, send to another function, or use in a UI label. That matters in real code because a function that returns data gives you control later, not just a momentary side effect.

If you are taking an Introduction to JavaScript class, this is the point where the homework starts feeling like actual programming instead of copy-paste drills.

Which JavaScript Return Mistakes Cause Bugs?

Most return bugs show up in the first 3 weeks of JavaScript practice, and they often hide in code that looks fine at a glance. One missing word can turn a clean function into `undefined`.

Frequently Asked Questions about JavaScript Functions

Final Thoughts on JavaScript Functions

JavaScript arguments and return values work because functions take named inputs, do something with them, and then send back a result when you ask for one. That pattern shows up in tiny examples like `add(2, 3)` and in bigger code like form checks, price math, and text formatting. Keep the two jobs separate in your head. Arguments enter the function call. Parameters live in the definition. Return values leave the function and give you something you can save, reuse, or pass along. That split sounds basic, but it saves a lot of confusion once your code has 3 or 4 functions talking to each other. Watch the common traps. A missing `return` gives you `undefined`. A `console.log()` only prints. A flipped argument order can make a correct-looking function behave badly without throwing an error. Those bugs frustrate beginners because the code seems polite while the result goes sideways. The best next step is simple: write 3 tiny functions by hand. Make one that adds 2 numbers, one that joins 2 strings, and one that returns a formatted sentence. Then call each function with different inputs and check the output. That small habit builds real control fast, and it turns function syntax into something you can actually use.

How UPI Study credits actually work

Ready to Earn College Credit?

ACE & NCCRS approved · Self-paced · Transfer to colleges · $250/course or $99/month

More on Introduction To Javascript
© UPI Study. This article and its educational content are solely owned by UPI Study and licensed under CC BY-NC-ND 4.0. It is not free to reuse or modify. Any citation must credit UPI Study with a direct link to this page.