function mergeDuplicates(itemid, quantity, singleCost, bulkcost) {
    var mergedArrays = { itemid: [], quantity: [], singleCost: [], bulkcost: [] };
    var uniqueItems = {};

    for (var i = 0; i < itemid.length; i++) {
        if (!uniqueItems[itemid[i]]) {
            uniqueItems[itemid[i]] = {
                quantity: 0,
                singleCost: singleCost[i],
                bulkcost: 0
            };
        }
        uniqueItems[itemid[i]].quantity += parseInt(quantity[i]);
        uniqueItems[itemid[i]].bulkcost += bulkcost[i];
    }

    for (var key in uniqueItems) {
        mergedArrays.itemid.push(key);
        mergedArrays.quantity.push(uniqueItems[key].quantity);
        mergedArrays.singleCost.push(uniqueItems[key].singleCost);
        mergedArrays.bulkcost.push(uniqueItems[key].bulkcost);
    }

    return mergedArrays;
}



//Array to reove Dash

function removeDashPart(str) {var parts = str.split(' - ');
var result = parts[0].toLowerCase();return result; }

