How do I get rid of NaN in the parameters pizza exercise?


#1

Based on the following:

const takeOrder = (topping, crustType) => {
  
  console.log('Order: pizza topped with ' + topping + + crustType);
};

takeOrder('mushrooms, thin crust ');

I get the following output:

Order: pizza topped with mushrooms, thin crust NaN (on the output screen)

I assume there is a extra space somewhere but am unable to identify it.


#2

Also, how do I use regular paragraph text for below the dashed line…to make this easier to read? (I figured the formatting in regards to showing the code more neatly)


#3

to join multiply variables in a string, a single plus is needed:

topping + crustType

now there is no longer NaN

there is an additional space here:

takeOrder('mushrooms, thin crust_');

replaced with underscore so you can see it


#4
const takeOrder = (topping, crustType) => {
  
  console.log('Order: pizza topped with ' + topping + crustType);
};

takeOrder('mushrooms, thin crust ');
takeOrder('pepperoni, stuffed crust ');

In the above example, I added the space. and deleted the extra “+” but I am still getting the below transcript on the output screen

Order: pizza topped with mushrooms, thin crust undefined
Order: pizza topped with pepperoni, stuffed crust undefined


#5

ah, i see. Your function has 2 parameters (topping and crustType) but at function call you only provide a single argument. So crustType is undefined


#6
const takeOrder = (topping, crustType) => {
{'Order: pizza topped with ' + crustType}  
  console.log('Order: pizza topped with ' + topping + crustype);
};
const takeOrder = (crust, crustType) =>

{'Order: pizza topped with ' + crustType}  
  console.log('Order: pizza topped with ' + topping + crustype);
};

takeOrder('mushrooms, thin crust ');
takeOrder('pepperoni, stuffed crust ');

I think I’m getting colder…:frowning:


#7

why did you add a second function?

here:

const takeOrder = (topping, crustType)

you define your function with 2 parameters: topping and crustType

which means, at function call you need to provide two arguments to satisfy the two function parameters, but if we then look at one of your function calls:

takeOrder('mushrooms, thin crust ');

we see only 1 argument ('mushrooms, thin crust '), so given there is no second argument, the second parameter (crustType) is undefined

Its important to understand when i use the term parameter (these are defined at function deceleration) and argument (function call)


#8
const takeOrder = (topping,crustType) => {
  console.log('Order: ' + 'pizza topped with ' + topping);
};

takeOrder('bacon, thin crust');

I still don’t really understand but this seems alot closer…


#9

at function call, why not simply provide two arguments to satisfy the two function parameters?


#10
  console.log('Order: ' + CrustType + 'pizza topped with ' + topping);
};

takeOrder('bacon, thin crust');

?


#11

pizza toppings and all

The above is a link to the exercise


#12

your function call:

takeOrder('bacon, thin crust');

it has one argument (a string), it should have two. How do we ensure it has two arguments?


#13
const takeOrder = (topping, crustType) => {
  console.log('Order: ' + crustType 'pizza topped with ' + topping);
};

takeOrder('bacon' + ' witth in crust');

Now there is a syntax error message


#14

arguments in the function call are separated by comma

What do i need to do, do help you more effective? I feel like many things i try/say do not come across as intended


#15

Are you referring to takeOrder?


#16

I explained what arguments are several times:

here is some general syntax to help you with it:

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

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

#17
const takeOrder = (crustType, topping) => {
  console.log('Order: ' + crustType, 'pizza topped with ' + topping);
};

takeOrder('thin crust', 'bacon');

I am letting you know that there is an error with marking this correct. Based on my own exploration and the guidance, I was able to find the answers… but it still marks it as incorrect.

Did I do anything wrong?

Here is the link again:
pizza toppings


#18

Nevermind, the program marks it as correct!


#19