title: Create map with parent key and filter data from object push it to the map- Javascript
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    con_data = {
        "0": {
          "Actual1920": 2379403,
          "Budget1920": 10121051.161450788,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Salary",
          "LedgereType": "Salary-Teaching",
          "RemainingAmount": 7741648.161450788,
          "leadgerLevel": "EBITDA"
        },
        "1": {
          "Actual1920": 0,
          "Budget1920": 0,
          "CostOwner": "Dr. Ratnavat",
          "LedgerBudget": "Salary",
          "LedgerType": "Salary-Teaching",
          "RemainingAmount": 0
        },
        "2": {
          "Actual1920": 0,
          "Budget1920": 0,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Salary",
          "LedgereType": "Salary-Contract &amp; Professional",
          "RemainingAmount": 0,
          "leadgerLevel": "EBITDA"
        },
        "3": {
          "Actual1920": 0,
          "Budget1920": 540098.7555555556,
          "CostOwner": "Vineeta S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Admission",
          "LedgereType": "Admission-Referral",
          "RemainingAmount": 540098.7555555556,
          "leadgerLevel": "EBITDA"
        },
        "4": {
          "Actual1920": 0,
          "Budget1920": 40835.600000000006,
          "CostOwner": "Vineeta S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Admission",
          "LedgereType": "Admission-Others",
          "RemainingAmount": 40835.600000000006,
          "leadgerLevel": "EBITDA"
        },
        "5": {
          "Actual1920": 0,
          "Budget1920": 1690058.304,
          "CostOwner": "Nitin P",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Advertisement",
          "LedgereType": "Advertisement- Print &amp; Others",
          "RemainingAmount": 1690058.304,
          "leadgerLevel": "EBITDA"
        },
        "6": {
          "Actual1920": 0,
          "Budget1920": 1115690.5056,
          "CostOwner": "Nitin P",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Advertisement",
          "LedgereType": "Advertisement- Web",
          "RemainingAmount": 1115690.5056,
          "leadgerLevel": "EBITDA"
        },
        "7": {
          "Actual1920": 0,
          "Budget1920": 223245.79200000002,
          "CostOwner": "Nitin P",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Advertisement",
          "LedgereType": "Advertisement -Printing Production",
          "RemainingAmount": 223245.79200000002,
          "leadgerLevel": "EBITDA"
        },
        "8": {
          "Actual1920": 0,
          "Budget1920": 300000,
          "CostOwner": "Vineeta S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Marketing",
          "LedgereType": "Marketing",
          "RemainingAmount": 300000,
          "leadgerLevel": "EBITDA"
        },
        "9": {
          "Actual1920": 0,
          "Budget1920": 764652.7777777778,
          "CostOwner": "Vineeta S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Scholarship &amp; Discounts",
          "LedgereType": "Scholarship &amp; Discount",
          "RemainingAmount": 764652.7777777778,
          "leadgerLevel": "EBITDA"
        },
        "10": {
          "Actual1920": 0,
          "Budget1920": 155843.62536,
          "CostOwner": "Jay S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Aicte &amp; Other Affiliation",
          "LedgereType": "Aicte &amp; Other Affiliation",
          "RemainingAmount": 155843.62536,
          "leadgerLevel": "EBITDA"
        },
        "11": {
          "Actual1920": 0,
          "Budget1920": 0,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Foreign Affiliation",
          "LedgereType": "Foreign Affiliation",
          "RemainingAmount": 0,
          "leadgerLevel": "EBITDA"
        },
        "12": {
          "Actual1920": 0,
          "Budget1920": 230132.22222222222,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Book/Tool Kits",
          "LedgereType": "Book/Tool Kits",
          "RemainingAmount": 230132.22222222222,
          "leadgerLevel": "EBITDA"
        },
        "13": {
          "Actual1920": 3000,
          "Budget1920": 711156.6,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Honorarium",
          "LedgereType": "Honorarium",
          "RemainingAmount": 708156.6,
          "leadgerLevel": "EBITDA"
        },
        "14": {
          "Actual1920": 0,
          "Budget1920": 50000,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Alumini",
          "RemainingAmount": 50000,
          "leadgerLevel": "EBITDA"
        },
        "15": {
          "Actual1920": 0,
          "Budget1920": 5000,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Convocation",
          "RemainingAmount": 5000,
          "leadgerLevel": "EBITDA"
        },
        "16": {
          "Actual1920": 0,
          "Budget1920": -2444.4444444444443,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Examination",
          "RemainingAmount": -2444.4444444444443,
          "leadgerLevel": "EBITDA"
        },
        "17": {
          "Actual1920": 0,
          "Budget1920": 50000,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Seminar",
          "RemainingAmount": 50000,
          "leadgerLevel": "EBITDA"
        },
        "18": {
          "Actual1920": 26880,
          "Budget1920": 21374.222222222223,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Inauguration",
          "RemainingAmount": -5505.777777777777,
          "leadgerLevel": "EBITDA"
        },
        "19": {
          "Actual1920": 177000,
          "Budget1920": 349402.77777777775,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Induction",
          "RemainingAmount": 172402.77777777775,
          "leadgerLevel": "EBITDA"
        },
        "20": {
          "Actual1920": 0,
          "Budget1920": 25000,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Placement",
          "RemainingAmount": 25000,
          "leadgerLevel": "EBITDA"
        },
        "21": {
          "Actual1920": 0,
          "Budget1920": 20746,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Student Practical",
          "RemainingAmount": 20746,
          "leadgerLevel": "EBITDA"
        },
        "22": {
          "Actual1920": 3411,
          "Budget1920": 20187,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Student Activity",
          "LedgereType": "Student Activity-Student related other Expenses",
          "RemainingAmount": 16776,
          "leadgerLevel": "EBITDA"
        },
        "23": {
          "Actual1920": 11310,
          "Budget1920": 110008.33333333331,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Membership &amp; Subscription",
          "LedgereType": "Membership &amp; Subscription",
          "RemainingAmount": 98698.33333333331,
          "leadgerLevel": "EBITDA"
        },
        "24": {
          "Actual1920": 0,
          "Budget1920": 170080.88888888888,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Uniform",
          "LedgereType": "Uniform",
          "RemainingAmount": 170080.88888888888,
          "leadgerLevel": "EBITDA"
        },
        "25": {
          "Actual1920": 51669,
          "Budget1920": 177297.12000000002,
          "CostOwner": "Sandip S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "House Keeping",
          "LedgereType": "House Keeping",
          "RemainingAmount": 125628.12000000002,
          "leadgerLevel": "EBITDA"
        },
        "26": {
          "Actual1920": 0,
          "Budget1920": 0,
          "CostOwner": "Sandip S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Hostel",
          "LedgereType": "Hostel-Canteen",
          "RemainingAmount": 0,
          "leadgerLevel": "EBITDA"
        },
        "27": {
          "Actual1920": 0,
          "Budget1920": 0,
          "CostOwner": "Sandip S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Hostel",
          "LedgereType": "Hostel-Other Consumables",
          "RemainingAmount": 0,
          "leadgerLevel": "EBITDA"
        },
        "28": {
          "Actual1920": 0,
          "Budget1920": 536948,
          "CostOwner": "Sandip S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Electricity",
          "LedgereType": "Electricity",
          "RemainingAmount": 536948,
          "leadgerLevel": "EBITDA"
        },
        "29": {
          "Actual1920": 0,
          "Budget1920": 255000,
          "CostOwner": "Sandip S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Security",
          "LedgereType": "Security",
          "RemainingAmount": 255000,
          "leadgerLevel": "EBITDA"
        },
  
      }
  
  
   this.new_data = Object.keys(this.con_data).reduce( (acc,currentKey)=&gt;{
    const item = this.con_data[currentKey]
    const ledgetBudgetType = item.LedgerBudget
     if( !acc[ledgetBudgetType] ){
       acc[ledgetBudgetType] = {}
     }
     const size = Object.keys(acc[ledgetBudgetType]).length
     acc[size] = item
     
     return acc
  }, {})
  console.log("New Data :",this.new_data);</code></pre>
  </div>
  </div>
  
  I have an array of objects. I want to filter data in and push it to a new object in which objects unique key which is common in objects.</p>
  
  <p>Parent key will be my LedgerBudget Key. I have tried with for loops with hasOwnProperty but no Luck! Also tried with Lodash but pushing only to unique ones.</p>
  
  <p>I want data formated in below format</p>
  
  <pre><code>new_data = {
  'Salary' : {
  
         "0" :  {
          "Actual1920": 2379403,
          "Budget1920": 10121051.161450788,
          "CostOwner": "Dr. Ratnavat",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Salary",
          "LedgereType": "Salary-Teaching",
          "RemainingAmount": 7741648.161450788,
          "leadgerLevel": "EBITDA"
         },
         "1": {
          "Actual1920": 0,
          "Budget1920": 0,
          "CostOwner": "Dr. Ratnavat",
          "LedgerBudget": "Salary",
          "LedgerType": "Salary-Teaching",
          "RemainingAmount": 0
          },
          "2": {
              "Actual1920": 0,
              "Budget1920": 0,
              "CostOwner": "Dr. Ratnavat",
              "LTRevExp": "Expense-EB",
              "LedgerBudget": "Salary",
              "LedgereType": "Salary-Contract &amp; Professional",
              "RemainingAmount": 0,
              "leadgerLevel": "EBITDA"
              },
  },
  "Admission" : {
      "0": {
          "Actual1920": 0,
          "Budget1920": 540098.7555555556,
          "CostOwner": "Vineeta S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Admission",
          "LedgereType": "Admission-Referral",
          "RemainingAmount": 540098.7555555556,
          "leadgerLevel": "EBITDA"
          },
      "1": {
          "Actual1920": 0,
          "Budget1920": 40835.600000000006,
          "CostOwner": "Vineeta S",
          "LTRevExp": "Expense-EB",
          "LedgerBudget": "Admission",
          "LedgereType": "Admission-Others",
          "RemainingAmount": 40835.600000000006,
          "leadgerLevel": "EBITDA"
          },
  }
  </code></pre>
  
  <p>}</p>