I'm sure this is an easy one, however my searches haven't helped as of yet.
When I push an array into another array, they nest a level deeper. The first array is at the correct depth.
var productArray = [{productID: currentProduct, productPrice: currentPrice, productName: productName, options: myOptions}];
if(localStorage.getItem("cart")){
var existingArray = JSON.parse(localStorage.getItem("cart"));
existingArray.push(productArray);
localStorage.setItem("cart", JSON.stringify(existingArray));
} else {
localStorage.setItem("cart", JSON.stringify(productArray));
}
Result:
0: Object { productID: "1", productPrice: "2.00", productName: "Chicken Sandwich", … }
1: 0: Object { productID: "1", productPrice: "2.00", productName: "Chicken Sandwich", … }
2: 0: Object { productID: "1", productPrice: "2.00", productName: "Chicken Sandwich", … }