Search code examples
javascriptcoffeescript

add Array of Object in an object coffeescript


I wish to add an array of objects in an object in coffeescript can't seem to be doing this Here's what I've tried :

params = 
  zone: "test"
  currency: "USD"
  products: [
    {
      name: "product"
      ID: "id"
    },
    {
      name: "product2"
      ID: "id2"          
    }
  ]

the problem is on the products part.

thanks


Solution

  • You don't need , for specifying element of array.

    params = 
      zone: "test"
      currency: "USD"
      products: [
        {
          name: "product"
          ID: "id"
        }
        {
          name: "product2"
          ID: "id2"          
        }
      ]