Skip to content

Instantly share code, notes, and snippets.

@siddharth-pandey
Created September 30, 2014 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddharth-pandey/2ec1a29af844dcfc22cc to your computer and use it in GitHub Desktop.
Save siddharth-pandey/2ec1a29af844dcfc22cc to your computer and use it in GitHub Desktop.
var array = [];
var instance = $(this);
array.push(getAnArrayItem(instance.val(), "1", "123.89")); //pass the values either by using harcode d values or from a input...
// function to use to get an item to push
var getAnArrayItem = function(product, quantity, price){ //parameters to construct an item
var item = null;
if(product && quantity && price) //these can be based on you requirements as some propeties is not mandatory
{
item = {
product: product,
quantity: quantity,
price: price
};
}
return item;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment