title: Separate and assign objects to variable from an array
body: <p>I have the following array that I need to loop through:</p>
  
  <pre><code>var arr = [{
    "id": 111,
    "wbs_name": "Mechanical",
    "parent": 'root',
  }, {
    "id": 222,
    "wbs_name": "Electrical",
    "parent": 111,
  }, {
    "id": 333,
    "wbs_name": "Systems",
    "parent": 111,
  },]
  </code></pre>
  
  <p>My output should be like this:</p>
  
  <pre><code> var mechanical = {
       "id": 111,
       "wbs_name": "mechanical",
       "parent": 0,
   },
  
   var electrical= {
       "id": 222,
       "wbs_name": "electrical",
       "parent": mechanical,
   },
  
   var systems = {
       "id": 222,
       "wbs_name": "systems",
       "parent": mechanical,
   },
  </code></pre>
  
  <p>I already tried looping through the array and pushing the object into another, but I don't know how to assign them to a variable at the same time (where the variable name is "wbs_name" and the "parent" is the variable name of some other parent object.</p>