title: Group an array of objects by unix time while filtering on nested values
body: <p>I'm dealing with OpenWeather API. My goal is to display the date and a timetable if that date (at any given time stamp) has windspeed &gt;= MIN_WIND_SPEED</p>
  <p><strong>Edit: Added input and expected output JSON</strong></p>
  <p>The object returned from the API looks like this:</p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;dt&quot;: 1632808800,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.5
      }
    },
    {
      &quot;dt&quot;: 1632819600,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.53
      }
    },
    {
      &quot;dt&quot;: 1632830400,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.05
      }
    },
    {
      &quot;dt&quot;: 1632841200,
      &quot;wind&quot;: {
        &quot;speed&quot;: 1.64
      }
    },
    {
      &quot;dt&quot;: 1632852000,
      &quot;wind&quot;: {
        &quot;speed&quot;: 2.39
      }
    },
    {
      &quot;dt&quot;: 1632862800,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.19
      }
    },
    {
      &quot;dt&quot;: 1632873600,
      &quot;wind&quot;: {
        &quot;speed&quot;: 4.03
      }
    },
    {
      &quot;dt&quot;: 1632884400,
      &quot;wind&quot;: {
        &quot;speed&quot;: 4.67
      }
    },
    {
      &quot;dt&quot;: 1632895200,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.93
      }
    },
    {
      &quot;dt&quot;: 1632906000,
      &quot;wind&quot;: {
        &quot;speed&quot;: 5.02
      }
    },
    {
      &quot;dt&quot;: 1632916800,
      &quot;wind&quot;: {
        &quot;speed&quot;: 4.86
      }
    },
    {
      &quot;dt&quot;: 1632927600,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.73
      }
    },
    {
      &quot;dt&quot;: 1632938400,
      &quot;wind&quot;: {
        &quot;speed&quot;: 2.99
      }
    },
    {
      &quot;dt&quot;: 1632949200,
      &quot;wind&quot;: {
        &quot;speed&quot;: 3.31
      }
    },
    {
      &quot;dt&quot;: 1632960000,
      &quot;wind&quot;: {
        &quot;speed&quot;: 4.29
      }
    },
    {
      &quot;dt&quot;: 1632970800,
      &quot;wind&quot;: {
        &quot;speed&quot;: 5.14
      }
    },
    {
      &quot;dt&quot;: 1632981600,
      &quot;wind&quot;: {
        &quot;speed&quot;: 5.86
      }
    },
    {
      &quot;dt&quot;: 1632992400,
      &quot;wind&quot;: {
        &quot;speed&quot;: 6.5
      }
    },
    {
      &quot;dt&quot;: 1633003200,
      &quot;wind&quot;: {
        &quot;speed&quot;: 5.81
      }
    },
    {
      &quot;dt&quot;: 1633014000,
      &quot;wind&quot;: {
        &quot;speed&quot;: 6.58
      }
    },
    {
      &quot;dt&quot;: 1633024800,
      &quot;wind&quot;: {
        &quot;speed&quot;: 4.98
      }
    }
  //...
  ]
  
  </code></pre>
  <p>I want to convert it into an object like this:</p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;key&quot;: &quot;Saturday 09/25&quot;,
      &quot;value&quot;: [
        {
          &quot;dt&quot;: 1632808800,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.5
          }
        },
        {
          &quot;dt&quot;: 1632819600,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.53
          }
        },
        {
          &quot;dt&quot;: 1632830400,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.05
          }
        },
        {
          &quot;dt&quot;: 1632841200,
          &quot;wind&quot;: {
            &quot;speed&quot;: 1.64
          }
        },
        {
          &quot;dt&quot;: 1632852000,
          &quot;wind&quot;: {
            &quot;speed&quot;: 2.39
          }
        },
        {
          &quot;dt&quot;: 1632862800,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.19
          }
        }
      ]
    },
    {
      &quot;key&quot;: &quot;Sunday 09/26&quot;,
      &quot;value&quot;: [
        {
          &quot;dt&quot;: 1632808800,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.5
          }
        },
        {
          &quot;dt&quot;: 1632819600,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.53
          }
        },
        {
          &quot;dt&quot;: 1632830400,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.05
          }
        },
        {
          &quot;dt&quot;: 1632841200,
          &quot;wind&quot;: {
            &quot;speed&quot;: 1.64
          }
        },
        {
          &quot;dt&quot;: 1632852000,
          &quot;wind&quot;: {
            &quot;speed&quot;: 2.39
          }
        },
        {
          &quot;dt&quot;: 1632862800,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.19
          }
        }
      ]
    },
    {
      &quot;key&quot;: &quot;Monday 09/27&quot;,
      &quot;value&quot;: [
        {
          &quot;dt&quot;: 1632808800,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.5
          }
        },
        {
          &quot;dt&quot;: 1632819600,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.53
          }
        },
        {
          &quot;dt&quot;: 1632830400,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.05
          }
        },
        {
          &quot;dt&quot;: 1632841200,
          &quot;wind&quot;: {
            &quot;speed&quot;: 1.64
          }
        },
        {
          &quot;dt&quot;: 1632852000,
          &quot;wind&quot;: {
            &quot;speed&quot;: 2.39
          }
        },
        {
          &quot;dt&quot;: 1632862800,
          &quot;wind&quot;: {
            &quot;speed&quot;: 3.19
          }
        }
      ]
    }
  //...
  ]
  
  </code></pre>
  <p>The logic should convert <code>dt</code> into <code>dddd MM/DD</code> and group all the <code>dt</code> of the same day together with <code>key</code> being the date in human readable. It should also remove dates that does not have wind &gt;= MIN_WIND_SPEED</p>
  <p>I'm trying with these functions to filter the timestamp that has <code>wind.speed</code> &gt;= MIN_WIND_SPEED and group the entries by key <code>dt</code></p>
  <pre class="lang-js prettyprint-override"><code>const list = weatherList.filter((i) =&gt; i.wind.speed &gt;= MIN_WIND_SPEED);
  
  const groupByDay = () =&gt;
    list.reduce((entryMap, entry) =&gt; {
      let selector = unix(entry.dt).format(&quot;dddd MM/DD&quot;);
  
      return entryMap.set(selector, [...(entryMap.get(selector) || []), entry]);
    }, new Map());
  </code></pre>
  <p>This method removes all of the time stamps that does not have wind.speed &gt;= MIN_WIND_SPEED. The results have the correct dates but the dates are missing the timestamps with <code>wind.speed</code> &lt; MIN_WIND_SPEED.</p>
  <p><strong>Current UI:</strong>
  <a href="https://i.stack.imgur.com/Yl8vw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yl8vw.png" alt="enter image description here" /></a></p>
  <p><strong>Expected UI:</strong>
  <a href="https://i.stack.imgur.com/Yh5ga.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yh5ga.png" alt="enter image description here" /></a></p>
  <p>In this example, Saturday and Sunday should NOT be displayed! Because thay don't have any timestamp that has wind &gt;= MIN_WIND_SPEED</p>
  <p>Thanks!</p>