JacobHsu
11/2/2014 - 1:48 AM

#JS Building a Cash Register

#JS Building a Cash Register

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


//call the add method for our items
var items = [0.98, 1.23, 4.99, 0.45];
for(i=0;i<items.length;i++){
    cashRegister.add(items[i]);
}


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