cost should be inside of cashRegister. Then you can reference it within your object methods with this.cost.