Parameters, arguments, and return values

Parameters make functions flexible. A parameter is a variable listed in a function's definition, and an argument is the actual value passed in when the function is called. For example, a function defined as area(width, height) that returns width times height can be called as area(3, 4), where 3 and 4 are the arguments, and it returns 12. A return value sends a result back to the code that called the function, so it can be stored in a variable or used in another calculation, unlike printing, which only displays a value. Variables created inside a function are usually local, existing only while the function runs, which keeps functions from accidentally interfering with each other. Writing general functions with parameters, instead of many nearly identical copies of code, is called procedural abstraction: you can use a function knowing what it does without needing to know how it works inside.

This explanation is AI-generated and can occasionally be wrong.

Vibistic AI

🔒 We never store your messages. The free built-in AI runs through Vibistic's own server, on Cloudflare's own AI infrastructure. You can also add your own API key to send messages straight from your browser to your AI provider instead.

  • Ask a question about Parameters, arguments, and return values, like "can you give me another example?"

Your notes

Test your knowledge

This test is AI-generated and can occasionally be wrong. If something looks off, use Report below.

No API key configured yet. Clicking below will ask whether to add one or take a free version of this test when one is available.