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

const getAverage = (numberOne, numberTwo) => {
  const average = (numberOne + numberTwo) / 2 ;

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…


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


Hi @arrayace93118,

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

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) => {
  //your codes

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

Hope this clears your doubt. Cheers! :slight_smile:


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


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:

You will start to understand why I said so.



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