2. Manually Add It Up?


#1


https://www.codecademy.com/courses/close-the-super-makert/0/2?curriculum_id=506324b3a7dffd00020bf661


Oops, try again. Have you called the method four items to add each itemCost? I do not understand why it is doing this


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


//call the add method for our items
this.total = this.total + 0.98;
this.total = this.total + 1.23;
this.total = this.total + 4.99;
this.total = this.total + 0.45;

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


#2

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

You're calling your function, not modifying the object.


#3

Thank you so much it worked


#4

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