title: How to create a new array from another array based on third array?
body: <p>I have a <code>structuredFormData</code> array with these values:</p>
  
  <pre><code>[
    {
      "season": "autumn",
      "firstContactPersonName": "John",
      "firstContactPersonPhone": "46442644",
      "secondContactPersonName": "Jhonny",
      "secondContactPersonPhone": "46442644",
    },
    {
      "season": "christmas",
      "firstContactPersonName": "Tommy",
      "firstContactPersonPhone": "46442644",
      "secondContactPersonPhone": "Thomas",
    },
  ]
  </code></pre>
  
  <p>I have another array holding the dates, <code>selectedDate</code> array: <code>["autumn=2020-08-28", "christmas=2020-12-28"]</code></p>
  
  <p>My function creates a new array <code>updatedStructuredFormData</code> and populate the new array with data for sending to backend. Or maybe just update the existing array <code>structuredFormData</code> ?</p>
  
  <pre><code>let updatedStructuredFormData = structuredFormData.map(x =&gt; {
              let season = x.season;
              x.date = selectedDate.find(e =&gt; e.indexOf(season) &gt; -1).split("=")[1];
              return x;
          });
  </code></pre>
  
  <p>The problem is, if i only select one date and the <code>dates</code> array looks like this: <code>["autumn=2020-08-28"]</code> i only want to populate these values into new array: </p>
  
  <pre><code>{
  "season": "autumn",
  "firstContactPersonName": "John",
  "firstContactPersonPhone": "46442644",
  "secondContactPersonName": "Jhonny",
  "secondContactPersonPhone": "46442644",
  }
  </code></pre>
  
  <p>I am new to JavaScript and need help how i can filter only the selected values in <code>dates</code> array. </p>
  
  <p>Expected outcome should be:</p>
  
  <pre><code>[
      {
        "season": "autumn",
        "firstContactPersonName": "John",
        "firstContactPersonPhone": "46442644",
        "secondContactPersonName": "Jhonny",
        "secondContactPersonPhone": "46442644",
        "date": "2020-08-28"
      }
  ]
  </code></pre>
  
  <p>If <code>selectedDate</code> array also have an date of christmas <code>["autumn=28-08-28", "christmas=2020-12-28"]</code>, then expected outcome would be:</p>
  
  <pre><code>[
      {
        "season": "autumn",
        "firstContactPersonName": "John",
        "firstContactPersonPhone": "46442644",
        "secondContactPersonName": "Jhonny",
        "secondContactPersonPhone": "46442644",
        "date": "2020-08-28"
      },
      {
        "season": "christmas",
        "firstContactPersonName": "Tommy",
        "firstContactPersonPhone": "46442644",
        "date": "2020-12-28"
       }
  ]
  </code></pre>
  
  <p>Thank you :)</p>