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.
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 1 | Column 2 | Column 3 |
|---|---|---|
| Parameter | Inside function definition | `function sum(a, b)` |
| Argument | At the call site | `sum(4, 9)` |
| Exists when | Function is written | Function runs |
| Common mix-up | Calling `a` an argument | `a` is a parameter |
| Runtime value | Named slot | Actual 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.
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`.
- Forgetting `return` means the function finishes without giving back a value. A function like `function add(a, b) { a + b; }` does the math but returns `undefined`.
- Returning too early stops the rest of the code from running. If you place `return` on line 2, the 5 lines below it never matter.
- Confusing `console.log()` with `return` prints data to the screen but does not hand that data back to the caller. Logs help you debug, not build outputs.
- Expecting a function to change an outside variable can backfire. `let total = 0` outside the function does not change unless your code writes to it on purpose.
- Assuming every function returns something creates false confidence. In JavaScript, a function with no return statement gives you `undefined`, not a hidden result.
- Mixing up argument order breaks output in a quiet way. `discount(0.2, 50)` is not the same as `discount(50, 0.2)`.
Frequently Asked Questions about JavaScript Functions
The most common wrong assumption is that parameters and arguments mean the same thing; they don't. Parameters live in the function definition, while arguments are the values you pass in at call time, like `add(2, 3)`.
A simple function takes arguments in, uses them inside the function, then sends one result back with `return`. In `function add(a, b) { return a + b; }`, `a` and `b` are parameters, and `add(2, 3)` passes arguments `2` and `3`.
This applies to anyone writing `function name(x) {}` in an introduction to JavaScript course, an online course, or an intro college credit class. It doesn't apply to people who only copy code without changing inputs or reading return values.
What surprises most students is that a function can finish running and still give back `undefined` if it never uses `return`. `console.log()` prints to the screen, but it does not give your caller a usable value back.
If you mix up arguments and returns, your function calls break fast. You might pass `5` and `7` into a function, but if you forget `return`, the caller gets `undefined`, and that kills later math, checks, or display code.
Most students print the answer with `console.log` and think the job is done. What actually works is to pass data in with arguments, use the parameters inside the function, and return the final value so the caller can keep using it.
You pass arguments when you call the function, and the function receives them through parameters. `greet('Maya')` sends one argument, while `function greet(name) { return 'Hi, ' + name; }` uses the `name` parameter and returns a new string.
Start by writing a 2-parameter function like `sum(a, b)` and calling it with 2 numbers, such as `sum(4, 6)`. Then replace `return` with `console.log` once, so you can see the difference between output and returned data.
A `return` statement sends one value back to the code that called the function, and that value can be a number, string, object, or array. `return 10` gives the caller `10`, while `return { total: 10 }` gives back an object.
Yes, some online course options in intro JavaScript come with ACE NCCRS credit or transferable credit, and they often let you study online at your own pace. That matters if you want college credit for a programming class instead of only a certificate.
Use arguments to send data into the function, and use `return` to send one result back out. If you need two results, return an object like `{ sum: 7, product: 12 }`, because JavaScript returns one value at a time.
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