title: how to create json object in angular js
body: <pre><code>this.addToCart = function(id,name,category,price) {
      alert(id+"name"+name);
  
      var eachProduct = [
          {
              "name": name,
              "id": id,
              "category":category,
              "price":price
          }
  
  
      ];
      alert(eachProduct.name);//I am getting undefine
      addedProductsList.push(eachProduct);
  
      sessionStorage.setItem("addedProductsList", addedProductsList);
  
      return "success";
  };
  </code></pre>
  
  <p>How to pass the function parameters to each product?</p>