Return 2: Parameters


I asked for the code from codeacademy, but I still don’t understand it.

  1. Why does it say “itemCount” on lines 8-9, while everything else says “orderCount”? Why shouldn’t they be the same?
  2. Why is it that some functions DON’T need parameters?

Here is the correct way:

Here is what I did: (I made everything say orderCount, AND I added that parameter to the functions getTax and getTotal.)

var orderCount = 0;

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

function getSubTotal(orderCount) {
  return orderCount * 7.5;

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

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

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




This function would work correct no matter what the variable is named.

function getSubTotal(foo) {
  return foo * 7.5;

That will raise a syntax error. Take out the dot.

That call should have an argument since the function takes a parameter.


Thank you, Roy! I can’t believe I didn’t catch that dot.