title: making array in map function
body: <p>I have some problem with my code when I create an array in this loop its repeat same as previous and not correct </p>
  
  <pre><code>getTimeShiftPermission = (data) =&gt; {
  const toDay = moment().format('[today] dddd')
  let newData = []
  if (data) {
    let newItem = {}
    data.map((i, index) =&gt; {
      if (i.start !== '00:00' || i.end !== '23:59') {
        console.log('index', index, i)
        newItem.start = i.start
        newItem.end = i.end
        newItem.day = moment.weekdays(index)
        newData.push(newItem)
      } else if (i.start === "" || i.end === "") {
        return []
      }
    })
    console.log('newData', newData)
    return newData
  } else {
    return []
  }}
  </code></pre>
  
  <p>and its result </p>
  
  <p><code>0: {start: "03:02", end: "14:51", day: "Thursday"}
  1: {start: "03:02", end: "14:51", day: "Thursday"}</code></p>