Can someone explain this code to me i dont get it at all


#1

let orderCount = 0;

const takeOrder = (topping, crustType) => {
orderCount++;
// what does ++ mean
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;
// what does itemCunt do
};

console.log(getSubTotal(orderCount));


#2

It is the increment operator that increments a value in place.

let a = 1;
a++;
console.log(a);    //->  2

It is a local variable of the getSubTotal function. The orderCount value is passed to function and a value computed for return.


#3

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