Cannot get the variable customPizza to work


#1

@Kyleaw


https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return?action=lesson_resume&link_content_target=interstitial_lesson

Cannot get the variable customPizza to work. Error message: Oops! The test returned an error. Maybe you have a syntax error, or a typo. See full error.


var makePizza = function (topping, crustType) {
return makePizza = topping, crustType;
};
  var customPizza = function (makePizza) {
return customPizza = topping, crustType;
  };   


  console.log('pepperoni', 'thick');


#2

Hi! How many of your steps are checked off on the left side of the screen?


#3

All of this is good!
The problem starts with what you are returning. It asks you to "use return to return the string that you previously used console.log to print before"
I believe that the string you are trying to return is, 'The ' + crustType + ' crust pizza topped with ' + topping + ' is done. Let\'s eat!'.

Additionally, when you're defining your variable, customPizza, you're not creating a function which is what you are trying to do. It asks you to call the makePizza function, which means passing the makePizza function arguments. The format of this is nameOfFunction(specificArgument, specificArgument)
The name of function in this case is makePizza, and you pass it argument by writing a topping then inserting a comma, then inserting a crus type.

The last thing I'll mention is that because you aren't defining a function, you do not need the curly braces with customPizza.


#4

I'm still working on the pizza.js code, and not getting very far.

Here is my updated code:

var makePizza = function (crustType, topping) {
return makePizza(thick, pepperoni);
};
customPizza = makePizza (crustType, topping)
return customPizza ('The ' + thick + ' crust pizza topped with ' + pepperoni + ' is done. Let\'s eat!');

console.log(crustType + topping);

I'm not getting any error messages or answers on the browser on the right-hand side. Just a red dot next to customPizza = makePizza(crustType, topping)

https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return?action=lesson_resume


#5

Try putting a semi colon, ;, on the end of that line.


#6

Kylea:

I tried that, it's still not working. Seems like I get through the early part of each lesson and then run into trouble in the later parts. So frustrating.

Here is the code, again, with an error message.

var makePizza = function (crustType, topping) {
return makePizza(thick, pepperoni);
};
customPizza = makePizza (crustType, topping);
customPizza ('The' + thick + 'crust pizza topped with' + pepperoni + 'is done. Let\'s eat!');

console.log(crustType, topping);

Here is the error code I'm getting:

Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.

/home/ccuser/workspace/javascript_101_Unit_3_v2/pizza.js:6
customPizza = makePizza(crustType, topping);
^
ReferenceError: crustType is not defined


#7

In your return statement, your makePizza parameters should just be crustType and topping. This way when you call your function, you can pass arguments to it like "thick" and "pepperoni". Your return statement is also missing the text string where the pizza is described.


#8

I left some more comments beneath your code above. Let me know if it helps :slight_smile:


#9

I'm still not quite getting it.

Here is my revised code, attempting to follow what you told me.

var makePizza = function (crustType, topping) {
return makePizza(thick, pepperoni);
};
customPizza = makePizza (thick, pepperoni);
return makePizza ('The' + crustType + 'crust pizza topped with' + topping + 'is done. Let\'s eat!');

console.log(customPizza);

Here is the error code that is being returned:

Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.

SyntaxError: /home/ccuser/workspace/javascript_101_Unit_3_v2/pizza.js: 'return' outside of function (5:0)
3 | };
4 | customPizza = makePizza (thick, pepperoni);

5 | return makePizza ('The' + crustType + 'crust pizza topped with' + topping + 'is done. Let\'s eat!');
| ^

Here is the link to the page:

https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return?action=lesson_resume

I want to apologize to you and Kyleaw if I'm bothering you. I have found some the directions in some of the exercises very confusing.And it's been quite frustrating to me.


#10

Make the alterations and run your code, it should work :slight_smile:


#11

My pizza.js has been moved to another lesson. How can it be returned to the proper lesson? it is here:

https://codecademy.com/courses/learn-javascript/lessons/functions/exercises/functions?action=lesson_resume

Under 2.functions


#12

Show us a screenshot of what you mean by that.


#13

If you cannot read it (somewhat small size), let me know and I'll resend it. What happened was that I got a dialog box telling me that this lesson was moved to a different lesson. It gave me the choice to fix it (don't remember the exact wording), meaning I would have to restore everything and start the entire section over again, or cancel. I pressed on cancel.

I hope this helps. I wish I could have gotten a screen shot with the dialog box in it.


#14

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