Return


#1

let orderCount=9;
const takeOrder = (topping,crustType) => {
console.log('OrderCount=orderCount+1: '+crustType + ’ crust topped with '+topping);
};
const getSubTotal=(itemCount)=>{
return itemCount*7.5
}

takeOrder(“mushroom”,“meat”);
takeOrder(“mush”,“vegetable”);
takeOrder(“salad”,“sandwish”);

console.log(getSubTotal(orderCount));

My question:
how to work for the code : console.log('OrderCount=orderCount+1: '+crustType + ’ crust topped with '+topping);
};
special for :'OrderCount=orderCount+1:
yes ,the code passed the lesson .
but if i cancelled the block of code ,it still works
const takeOrder = (topping,crustType) => {
console.log('OrderCount=orderCount+1: '+crustType + ’ crust topped with '+topping);
};

why the block above code doesnot work ?thanks


#2
let orderCount=9;

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

const getSubTotal = (itemCount) => itemCount*7.5;

takeOrder('mushroom','meat');
takeOrder('mush','vegetable');
takeOrder('salad','sandwish');

console.log(getSubTotal(orderCount));

I would not try to add one to orderCount in your console.log. Split it up to make it a little easier to read. It was not working because you had the logic in a string in your console.log.
Now, if you did want to put the logic in the console.log, I would recommend using the ES6 backtick syntax with the ${} syntax. Like so.

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

#3

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