# Can you label the parts of a numerical function (described below)?

#1
``````const getAverage = (numberOne, numberTwo) => {
const average = (numberOne + numberTwo) / 2 ;
console.log(average);
};

getAverage(365, 27);
``````

Use the below one as a reference:

``````//  function declaration with 2 parameters
const exampleFunction(parameter1, parameter2) => {
console.log(parameter1, parameter2);
}

// function call with 2 arguments
exampleFunction('argument1', 'argument2')
``````

why does this the pizza exercise in basic function example not provide multiple call outs

In the pizza example, it would be:

``````takeOrder: ('thin crust');
takeOrder: ('bacon');
``````

and so on, each topping corresponding to a topping (like peperoni) and each crust type, in a seperate takeOrder line, as thick crust, and then on a seperate line, stuffed crust…

#2

Is the short answer, that’s just the way it is?

#3

You can have multiple parameters for one function, you just need to call/invoke with the function with the same amount of arguments.

To give an example:

``````const favoriteFruits = ( fruit1, fruit2, fruit3 ) => {
console.log('My favorite fruits are: ' + fruit1 + ', ' + fruit2 + ' and ' + fruit3 );
}

//call the function with each argument enclosed with single quotes '  ' or double quotes "    "
favoriteFruits('apple','orange','pear');  //<== notice the same amount of arguments you need to provide

//another one
favoriteFruits('papaya','banana','grape');
``````

It will print to the console:

``````My favorite fruits are: apple, orange and pear
My favorite fruits are: papaya, banana and grape
``````

So for the pizza exercise, you can have:

``````const takeOrder = (topping,crustType) => {
};

takeOrder('thin crust' , 'bacon'); //<== calling the function with two arguments enclosed with '   ' each.
``````

Hope this clears your doubt. Cheers!

#4

Wouldnt the last line ( //another one//) need to be called favoritefruits1 (i.e., not exactly the same name as the first) to avoid error?

#5

Nope. I’m basically reusing the function. The same function can be used/invoked/called many times.

If you call `favoriteFruits1`, the code wouldn’t work because there’s no defined variable named `favoriteFruits1` and will get this error instead:

``````ReferenceError: favoriteFruits1 is not defined
``````

Try play around with the code I provided here:
https://repl.it/NwvP/0

You will start to understand why I said so.

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.