Convert array into key value pair

             let transformedData ={}
             finalItemArray.forEach(item => { //finalItemArray is array of object
                let prodGroup = item.ProductGroup;
            
                // Create an object for the current item excluding "ProductGroup"

                // Initialize an array for the current "ProductGroup" if it doesn't exist
                transformedData[prodGroup] = transformedData[prodGroup] || [];
           
                // Add the current item to the array
                transformedData[prodGroup].push(item);
                
            });

Leave a comment

Your email address will not be published. Required fields are marked *