Is this the wrong way of doing , I provided value in the beginning as property of object ,then why my code is not working?


#1

var cashRegister = {
total:0,
Eggs:0.98;
Milk:1.23;
Magazine:4.99;
Chocolate:.45;
add: function(itemCost){
this.total += itemCost;
}
};

cashRegister.add("Eggs ");
cashRegister.add("Milk");
cashREgister.add("Magazine");
cashRegister.add("Chocolate");

//call the add method for our items

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


#2

There appears to be some discrepancy between the above code and what is asked for in the instructions. Perhaps go back a couple of steps and give them another read.


#3

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