Pizza Error


#1

After the lesson 6 ended i started playing a bit with the code, and ended up with this:

let itemCount = 0
let iWantSoda = 0


const takeOrder = (topping, crustType) => { itemCount++
  console.log("Order: " + crustType + " Pizza topped with " + topping)
                                           
};


const countSoda = (flavor) => { iWantSoda++
  console.log("Order: " + flavor + " Soda")
                               
};


const getSubTotal = (itemCount, iWantSoda) => {
 	if (iWantSoda > 1) {       
    	return "Sub Total: " + (itemCount * 7.5) + (iWantSoda * 5.5) + "$"
                     } else if (iWantSoda === 0) {
                     return "Sub Total: " + itemCount * 7.5 + "$"
                     }
                     };


const tax = 0.28
const countTaxes = (tax) => { tax
	if (iWantSoda > 1) {
  return "Taxes: " + ((itemCount * 7.5) * tax) + ((itemCount * 5.5) * tax) + "$"
} else if (iWantSoda === 0) {
  return "Taxes: " (itemCount * 7.5) * tax + "$"
};

                             
const getTotal = () => {
  if (iWantSoda > 1) {
  return "Total: " + (((itemCount * 7.5) * tax) + itemCount * 7.5) + (((itemCount * 5.5) * tax) + itemCount * 5.5) + "$"
  } else if (iWantSoda === 0) {
    return "Total: " + ((itemCount * 7.5) * tax) + (itemCount * 7.5) + "$"
  }
};


takeOrder("mushrooms", 'thin crust')
takeOrder("mushrooms", 'thick crust')
takeOrder("mushrooms", 'chicago style')
takeOrder("mushrooms", 'whole wheatt')
takeOrder("mushrooms", 'italian')
takeOrder("mushrooms", 'italian')
takeOrder("mushrooms", 'italian')
takeOrder("mushrooms", 'italian')
takeOrder("mushrooms", 'italian');

countSoda("Red Rock");


console.log(getSubTotal(itemCount, iWantSoda))
console.log(countTaxes(tax))
console.log(getTotal())

When i try to run the code, it gives me the error “SyntaxError: Unexpected token )” but i cant locate where is the syntax error. Could someone help me? (and if i have another error in the code, ill be really thankful if is pointed)


#2

Various kinds of brackets (([{) need to be closed in the order they were opened

nodejs puts your module inside a function, and your code still have brackets open, and because it’s not a (, the ) which is added by nodejs is therefore unexpected

The syntax error isn’t in a particular location. The problem is that by the end you haven’t closed off all brackets.


#3

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