133k views
3 votes
Describe how arguments work in a function.

User RickDavis
by
8.0k points

2 Answers

2 votes

Final answer:

In a function, arguments are the values that are passed into the function when it is called. They allow the function to receive input and perform operations or calculations with that input.

Step-by-step explanation:

Arguments can be variables, constants, or even other functions. For example, consider a function called addNumbers that takes two arguments, num1 and num2, and returns their sum:

function addNumbers(num1, num2){
return num1 + num2;
}
let result = addNumbers(5, 7); // The arguments 5 and 7 are passed into the function

In this example, the arguments 5 and 7 are passed into the function addNumbers when it is called. The function then adds these two numbers together and returns the result, which is stored in the variable result.

User Zbw
by
8.0k points
6 votes

Answer:In a programming function, arguments are values passed to the function when it's called. These values provide input to the function, allowing it to perform operations or calculations. Functions can take multiple arguments, and their types and order must match the function's parameter definition. Parameters act as variables within the function, representing the values passed as arguments during the function call. This mechanism enables functions to be versatile

Step-by-step explanation:

User David Tang
by
8.1k points