3. Short term memory


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
While the code is working properly, I’m not sure what is the role “this.add” plays in the scan method. Could someone please help explain to me why I can’t just put a flat number but instead I need to put this.add?

```

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

scan: function (item) {
    switch (item) { 
    case "eggs": 
        this.add(0.98); 
        break;


    }
    return true;
}

};

<do not remove the three backticks above>

#2

The methods have a context, cashRegister, referenced internally as this.

Notice that we call cashRegister.scan() from the outside, but this.add() from inside the object. This is known as execution context. Inside a method, local properties are referred as this.property. For example, this.total.

Is this starting to make sense?