3. Short-Term Memory: Why's a comma ( , ) needed after the "add" method


#1


Why is the comma needed after "the new add method" rather than a semi-colon???

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


var cashRegister = {
    total: 0,
//insert the add method here    
    add: function(itemCost) { 
        this.total += itemCost;
    }, //<--Why a comma???

Thanks,
Katsurio


#2

Hi the cashRegister is an object so inside a object you separate each propriety/ propriety-value with a comma

var Object = {

   //the first object
   fred: {
        name: "fred", <--
        age: 10
   }, <--
   
   //the seconde object
   ted: {
       name: "Ted", <--
       age: 0
   }.

   ...
}

#3

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