Need help with learn javascript 5/7 calling Functions


#1

Hi there! I'm really struggling on the calling function command. I think at this point I understand the general concept about how to make functions and how functions work but I really need to get this part of javascript down before I go onto the next step. Below is my code. Where am I gong wrong?

var orderCount = 0;

var makePizza = function takeOrder(topping, crustType) {

console.log("'The' +crustType + 'and the ' + topping + 'is really good. Let/'s eat now.");
orderCount = orderCount + 1;

}

function getSubTotal (itemCount) 
{
return itemCount * 7.5 ;}
takeOrder('cheese', 'thick');
takeOrder('pepporni', 'deep-dish');
takeOrder('Sausage', 'stuffed crust');
console.log(getSubTotal(orderCount));

#2

When you define a function in a variable, the variable name is the function name. This means that this:
var makePizza = function takeOrder(topping, crustType)
Should really be this:
var takeOrder = function (topping, crustType)

Also, in your getSubTotal() function, I would change it to make it look a bit neater:

function getSubTotal (itemCount) {
return itemCount * 7.5;
}

Although people don't talk about it often, readability is very important in coding!

If this answer helped you, please be so kind as to mark it as the solution to your question. Thanks :slight_smile:


#3

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