Why "itemCount * 7.5" instead of "orderCount * 7.5" How does java know what an "itemCount" is?
We don't know unless you post your code and a link to the exercise
console.log('Order: '+crustType+' crust pizza with
I'm doing exactly the same exercise. I think I've kind of "solved it". Let me try and help:
in your last line of code, "console.log(getSubTotal(orderCount));" , you are CALLING the function, and telling it: "Apply orderCount as the new parameter for the function getSubTotal", since orderCount is the argument.
Which means that now itemCount has become orderCount (and since orderCount has a value of 3, because we have 3 orders, itemCount now also has a value of 3, and thus, since 7.5*3 equals 22.5m, thats is why you get your result)
I'm a newbie just like you, I tried to explain it to the best of my abilities. I'm currently struggling in Functions 6/7, so yeah, it gets even more hellish!
Second: As I don't know what your error message was, I just ran your code through Chrome's dev tools console, and the only error that comes up is;
Uncaught SyntaxError: Invalid or unexpected token
That means something is in the wrong place. It didn't take me long to see it;
console.log('Order: '+crustType+' crust pizza with '+topping);
The problem is in this part, and it's the blank line here. All of this should be in one line,
console.log('Order: ' + crustType + ' crust pizza with' + topping);
Thanks, that's what I wanted to Know. Good luck on your progress.
That wasn't my question, I didn't state I got an error message. Thanks anyway I appreciate the response.
Wow, thank you for that explanation, and thank you to @dchaka for asking the very question I had.
I was banging my head on the desk trying to figure it out too. I kinda get it now, although it seems like it could've been explained better in the conclusion to the instructions. I think this must be a very confusing point for most people going through this course if they're really trying to understand how functions work.
I can't help but think the same output could have been achieved in a simpler-to-understand program, but I'm way too new at this to detail how.