FUNCTIONS Return


#1

How does itemCount know what to count? I understand the result, but am not clear where itemCount came from and how it knows what to count - thank you

So sorry - here is the code


let orderCount = 0;

const takeOrder = (topping, crustType) => {
orderCount++;
console.log('Order: ’ + crustType + ’ pizza topped with ’ + topping);
};

takeOrder(‘mushroom’, ‘thin crust’);
takeOrder(‘spinach’, ‘whole wheat’);
takeOrder(‘pepperoni’, ‘brooklyn style’);

const getSubTotal = (itemCount) => {
return itemCount * 7.5;
};

console.log(getSubTotal(orderCount));


Here is the url

https://www.codecademy.com/courses/learn-javascript-functions/lessons/functions/exercises/return?action=resume_content_item&course_redirect=introduction-to-javascript


#2

No code? No exercise url? Please include code and preferable also exercise url, so we at least know what the code looks like (we don’t know all the exercises from the top of our head)

if i had to guess, i would say itemCount is a function parameter. Parameters are defined when you define a function, and parameter(s) get there value from argument(s) at function call.

parameters are placeholder until they get a value (from argument at function call)


#3

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