Whoops, looks like something went wrong 2


#1

My next problem. I really need a sanity check here. I am looping, creating objects, adding to arrays etc. However, something blows up my code when I try to push into an array.

if (event.response.content) {
event.response.content_changed = true;

var storeId = -99;
var myStore = {};
var gfProductCount = 0;
var productsArray = [];
var storeArray = [];
var newRecord = {};
var cnt = 0;


lodash._.each (event.response.content, function( record ) {
    if(storeId != record.storeId ){
        if(cnt === 0){
            storeId = record.storeId;
            myStore["id"] = record.id;
            myStore.products = [];
            newRecord.storeId = record.storeId;
            productsArray.push(record.nfCode);
            myStore["storeGfCount"] = myStore["storeGfCount"] + 1;
        }else{
            myStore["products"] = productsArray;
            storeArray.push(store)
            myStore= {};
            myStore.products = [];
            productsArray = [];
            newRecord.storeId = storeId; 
        }

    }else{
        productsArray.push(record.nfCode);
        myStore["storeGfCount"]= myStore["storeGfCount"] + 1;

    }
    cnt++;
});
myStore["products"].push(productsArray);
storeArray.push(myStore);   <<<<<<<=========== This crashes the event. WHY?
newRecord.record = storeArray;

return newRecord;
}


#2

my loop has to be:

lodash._.each (event.response.content.record, function( record ) {