I don’t understand 2 things:
- what value does itemCount gets?
- what’s wrong with my code?
I don’t understand 2 things:
Did you call the getSubTotal function with passing in the orderCount as a parameter?
As an argument, to be factual, but yes, your function call has no argument, orderCount
.
But where should i type it? inside the getSubTotal(orderCount) ??
Yes, just as you have written it above.
But i get this output: Your subtotal is NaN
That means it doesn’t have any value right?
Please post your code, not a screenshot.
You have a parameter for the function getSubTotal(). But when you call it, you don’t give it a parameter. Look at this:
var nameCaller = function(name) {
console.log("Hello " + name);
}
nameCaller() <-- you need an argument, like "Sam" or "Tom"
Try changing that with your code.
In the call expression, it is not a parameter, but an argument. The parameter is the receiving variable.
Examples should not go against normal practice. It is never a good idea to name a function and its variable the same thing.
just the terminology.
function foo(parameter) {
}
foo(argument);
I see… Oh no! I was wrong. He is asking what value item count gets. Sorry!
We’re still waiting to see the member’s code. If there is no response then this will end up as an unresolved topic and will get removed eventually.
@mtf I know whats wrong with the code now.
I fixed it already, but still i didn’t entirely understand the function of return
let orderCount = 0;
const takeOrder = (crustType, topping) => {
orderCount +=1;
console.log('Order : ’ + crustType + ’ pizza topped with ’ + topping);
}
const getSubTotal = (itemCount) => {
return itemCount * 7.5;
}
takeOrder(‘thin’, ‘pepperoni’);
takeOrder(‘thick’, ‘sausage’);
takeOrder(‘normal’, ‘ham’);
console.log(getSubTotal(orderCount));
Also, i don’t have clear yet where does itemCount gets its value
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.