Item Count


Hey everyone, I finished the functions exercise but I have a question. What does item count do exactly. I've been looking at the code trying to figure out how it all works in my head but I don't understand itemCount.

Where is the value coming from thats multiplied with 7.5? I'm not really sure how to explain it. Sorry if this is confusing. Is it being put into getSubTotal?

Would write more but it just makes my head spin. Perhaps coding isn't for me.

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;

function getTax() {
  return getSubTotal(orderCount) * 0.06;

function getTotal() {
  return getSubTotal(orderCount) + getTax();

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



itemCount is the pizza, 7.5 is its price.

You receive an order and you want to calculate the total price right? You have the orderCount (number of pizzas ordered), you calculate the tax etc, but how can you know the total without the unit price?

I wouldn't say that coding isn't for you. Coding is different from programming. Programming is analyzing a problem, come up with solutions, and then code that solution. Analyzing is done in plain English, in your head or written on paper (and that's 95% of the job), whereas coding is the remaining 5%. If you can't analyze, and thus can't come up with a solution, coding it will be very difficult.

If, down the road, you find that you're not an analytic person (most people aren't), you might always pivot towards Web Design (HTML / CSS). These require less analytical skills. If you want to be a front-end developer, you're gonna need Javascript, and there's a bit more logic involved than HTML & CSS.

But before you call it a day (if you do), I'd invite you to persevere. Try to think long and hard about the problem you're trying to solve, and come up with a bunch of solutions. It's a mental process, and if you succeed you'll eventually be able to think in code, which is great.

All the best.


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