What's wrong with this code?


#1

error says : Did you declare a variable named orderCount set equal to the number 0?

here is the code , it runs and displays the out put tho:

var orderCount = 0;

function takeOrder(topping, crustType) {
console.log('Order: ' + crustType + ' crust topped with ' + topping);
orderCount = orderCount + 1;
}

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

takeOrder('bacon', 'thin');
takeOrder('pepperoni', 'regular');
takeOrder('pesto', 'thin');

console.log(getSubTotal(orderCount));


#2

It says your orderCount should be 0, what is its value after running your code?


#3

I have the same code and the same error ....

var orderCount = 0;

function takeOrder(topping, crustType) {
console.log('Order: ' + crustType + ' crust topped with ' + topping);
orderCount = orderCount + 1;
}

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

takeOrder('bacon', 'thin');
takeOrder('pepperoni', 'regular');
takeOrder('pesto', 'thin');

console.log(getSubTotal(orderCount));


#4

I put to slashes in front of ,eg: //orderCount = orderCount + 1; it
worked.I removed the slashes afterwards and the program did not have any
problems removing them. Something about the program that thinks you are
skipping a step,not the js issue.


#5

It also worked for me here, thanks!


#6

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