title: Mapping array in Vue JS
body: <p>I'm developing a small application in <code>VueJS 2.0</code> where I'm having a data set something like this:</p>
  
  <pre><code>{"data":
      [
          {
              "id":8,
              "salutation":"Mr",
              "first_name":"Madhu",
              "last_name":"Kela",
              "number":"2343253455",
              "mobile":"3252345435",
              "email":"madhu@reliancemf.com",
              "alt_email":null,
              "address":"Mumbai BKC",
              "city":"Mumbai",
              "state":null,
              "country":"India",
              "profile":null,
              "sectors_interested":"[\"Insurance\",\"Infrastructure\",\"Information Technology\",\"hevy machines\",\"Healtcare\"]",
              "companies_interested":"[4]",
              "interactions_count":11,
              "client_interactions_count":0,
              "company":[
                  {
                      "id":7,
                      "name":"Reliance MF",
                      "address":"Mumbai BKC",
                      "city":"Mumbai",
                      "state":null,
                      "country":"India",
                      "type":"Investor",
                      "sub_type":"Mutual Fund",
                      "is_client":0,
                      "pivot":{
                          "contact_id":8,
                          "company_id":7,
                          "created_at":"2017-07-01 17:07:08",
                          "updated_at":"2017-07-01 17:07:08"
                      }
                  }
              ]
          },
          {
              "id":7,
              "salutation":"Ms",
              "first_name":"XYZ",
              "last_name":"ABC",
              "number":"1847171087",
              "mobile":"8327523057",
              "email":"skbkjgerbra@dabflvdjf.com",
              "alt_email":null,
              "address":"Mumbai",
              "city":"Mumbai",
              "state":null,
              "country":"India",
              "profile":null,
              "sectors_interested":"[\"Insurance\",\"Information Technology\",\"Infrastructure\",\"hevy machines\"]",
              "companies_interested":"[6,4]",
              "interactions_count":8,
              "client_interactions_count":0,
              "company":[
                  {
                      "id":3,
                      "name":"Franklin Fun",
                      "address":"Mumbai",
                      "city":"Mumbai",
                      "state":null,
                      "country":"India",
                      "type":"Investor",
                      "sub_type":"Mutual Fund",
                      "is_client":0,
                      "pivot":{
                          "contact_id":7,
                          "company_id":3,
                          "created_at":"2017-07-01 16:59:41",
                          "updated_at":"2017-07-01 16:59:41"
                      }
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I want map these values something like this:</p>
  
  <pre><code>return this.model.map(d =&gt; ({
      name: d.first_name + ' ' +d.last_name,
      company: d.company[0].name,
      email: d.email,
      mobile: d.mobile,
      profile: d.profile,
      count: d.interactions_count ? d.interactions_count : d.client_interactions_count
  }))
  </code></pre>
  
  <p>Also as you see in the code I want to place <code>interactions_count</code> by comparing i.e. if <code>interactions_count</code> is 0 I want to map with <code>client_interactions_count</code>, I'm unable to get company name from the first array parameter, and order it with the <code>count</code> in descending order whatever it comes by response. Help me out in this. Thanks.</p>