What's wrong here?


#1

var cashRegister = {
total:0,
add: function(itemCost) {
this.total += itemCost;
}
};

//call the add method for our items

cashRegiter.add(0.98);
cashRegister.add(1.23);
cashRegister.add(4.99);
cashRegister.add(0.45);

//Show the total bill
console.log('Your bill is '+ this.total);


#2

console.log('Your bill is '+ this.total);

You can no longer use "this.total" when you are outside of the Object. "this.total" refers to a variable inside the Object which is in this case "cashRegister". So since we are no longer inside of "cashRegister" we'll have to call the object so it'll know which variable we're referring to.

console.log('Your bill is '+ cashRegister.total);