I am having issues with functions


#1
Please help me because this makes no sense. The code is the following: orderCount = 0 function takeOrder(topping, crustType) { console.log('Order: ' + crustType, 'topped with ' + topping); orderCount += 1; return orderCount; }

takeOrder(‘bacon’, ‘thin crust’);
takeOrder(‘pears’, ‘thick crust’);
takeOrder(‘apples’, ‘cheese crust’);
console.log(‘Number of pizzas ordered:’, orderCount);
console.log('total cost of pizzas: ', (orderCount*7.5));

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Here is the link to the excercise
https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return?action=lesson_resume&link_content_target=interstitial_lesson
I have no idea why codeacademy will not accept this even though it works
error codes:
Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.
/home/ccuser/workspace/javascript_101_Unit_3_v2/pizza.js:3
orderCount = 0;
^

ReferenceError: orderCount is not defined
at pizza.js:1:1
at Object. (pizza.js:12:1)
at Module._compile (module.js:571:32)
at loader (/home/ccuser/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ccuser/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:488:32)
at Object.load (/home/ccuser/node_modules/rewire/lib/moduleEnv.js:20:18)
at internalRewire (/home/ccuser/node_modules/rewire/lib/rewire.js:57:15)
at rewire (/home/ccuser/node_modules/rewire/lib/index.js:11:12)
at Object. (test.js:3:15)
at Module._compile (module.js:571:32)
at loader (/home/ccuser/node_modules/babel-



Replace this line with your code. 



#2

When defining a VARIABLE
try to use the var keyword
like
var myVar =0;

In your code you will have to use the double-quote-"
as it seems your single-quote- is NOT recognized as such…
For instance
takeOrder("bacon", "thin crust");


#3

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