Functions: Parameters II Pizza

It partly works, but I don’t understand why it’s outputting “order a pizza” in the middle of the two it is outputting properly. It’s ‘True’, so it shouldn’t be saying ‘Order a pizza’. And it says “Expected Function”. How is it working at all if it’s expecting a function that it’s clearly executing.
My head hurts, and can’t move forward. aargggg…help please. Thanks!

p.s. Actually, I see that the next lesson button is green to go, but I’m not comfortable with it saying “Expected Function” with a big red X next to it.

Your code does not appear to follow the instructions to the letter and takes liberties with extra code and logic. Perhaps pass the lesson first, with the expected code and then explore once your code is accepted. Remember to keep a copy of your successful code before exploring.

Where does pizza get defined? We’re a little confused by that logic. Help us out.

1 Like

Thanks mtf,

I thought I did follow the instructions. I took no unintended liberties.

Pizza is defined, it got cut out of the screen shot…sorry.
var pizza = true; … at the very top.
I guess I can start over, again. I’ve already done that several times.

1 Like

Sorry if that sounded accusatory, not intended. The code looks a little more than what would be expected given the lesson context, but then I am still only guessing given that you left out the link to the exercise. And raw text code is much more helpful than a screenshot, which by itself gives only so much information, and none that we can grab and paste into our own editor for testing.

1 Like

var pizza = true;

takeOrder(topping, crustType)

if (pizza) {
console.log(‘You ordered a pizza:’ +'with '+ topping, crustType);
pizza = false;

} else {
console.log(‘Order a pizza’);
pizza = true;

takeOrder(‘black olives’, ‘cheesey crust’);
takeOrder(‘sweet peppers’, ‘garlic crust’);
takeOrder(‘ham’, ‘pineapple crust’);


You ordered a pizza:with black olives cheesey crust
Order a pizza
You ordered a pizza:with ham pineapple crust

1 Like

This code in Parameters II looks nothing like yours.

let orderCount = 0;
const takeOrder = (topping, crustType) => {
  orderCount = orderCount + 1;
  console.log(`Order: ${crustType} pizza topped with ${topping}`);

Even if it works in your browser, that doesn’t meat the above will work in others. Never write function on its own line.

function takeOrder(topping, crustType) {}


var takeOrder = function (topping, crustType) {};

or, like above,

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

It’s more readable, for one, but also less of a surprise to the SCT.

Pass this lesson, then we can explore your ideas further.

1 Like

Well, my screenshot shows that I am in the parameters II section. It’s the pizza assignment. Create a function takeOrder and pass it variables topping, crust. I haven’t yet come across anything to do with what you just pasted. That might be next.

1 Like

Do you know how many JavaScript tracks there are, and how many JS courses in general? We don’t have them on speed dial and if you are too unconcerned to supply a link then so be it if you wait for hours for a reply. You want help, then help others to help you. Give the information that best serves a speedy reply and a correct response. Otherwise you are just wasting your time

Then I’m not sure what you’ve been reading or following. Where did I come up with that code months ago when I did this unit? Are you reading the lessons or just racing through?

1 Like

Got it working.
First, it didn’t care about the function name being on next line.
It Did care that I was outputting topping first, then crust type.
This learning program checks that apparently and expects it to be to exact.
I didn’t realize I was outputting in the opposite order, nor did I think it mattered. But, it does…so, lesson learned.


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