Functions 5 Return. Why cost is 0?


var orderCount = 0;
function getSubTotal (itemCount){
return itemCount*7.5;
function takeOrder (topping, crustType) {
console.log ('Order: ' +crustType +' pizza topped with ' + topping);
return orderCount=orderCount++;
takeOrder('bacon', 'thin crust');
takeOrder('tomat', 'jhf');
takeOrder('ytt', 'uytt');

Why i get cost 0? And where I can find already made correct codes?


First off, just a minor thing, remove the semi-colon at the end of your first function (you don't need it) :slight_smile:

Regarding your error, when you return something at the end of a function you are returning something like a value calculated in the function. You only need to do that in your getSubTotal() function because you're taking a value from it.

Go into your takeOrder() function, and change return orderCount=orderCount++ to orderCount++. You are simply adding to the orderCount variable, meaning you don't need to return anything.


Thanx. Do you know where i can find the premade codes?


Can you expand on 'premade'? Do you mean the original code provided?

And if my solution helped, feel free to mark it as a solution and feel free to like it :slight_smile:


I mean, are there any done codes for the excersises, so I could compare them to what i made?


There are no pre-written solutions to the exercises. I would provide my own solution, but I haven't done that course (I did the original JavaScript course).


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