title: Optimization in resetting the values ​of an array
body: <p>Good evening everyone, I ask you my question by specifying that I have found a solution, but I would be interested to know if it can be optimized and improved to favor performance.
  I have the following subject given in response to a call to my server:</p>
  <pre><code>{
      &quot;status&quot;: 200,
      &quot;error_code&quot;: 0,
      &quot;data&quot;: {
          &quot;2022-04-15&quot;: {
              &quot;dots&quot;: [
                  2
              ]
          },
          &quot;2022-04-19&quot;: {
              &quot;dots&quot;: [
                  2
              ]
          },
          &quot;2022-04-20&quot;: {
              &quot;dots&quot;: [
                  1
              ]
          },
          &quot;2022-04-25&quot;: {
              &quot;dots&quot;: [
                  1
              ]
          },
          &quot;2022-04-26&quot;: {
              &quot;dots&quot;: [
                  2,
                  3
              ]
          },
          &quot;2022-04-27&quot;: {
              &quot;dots&quot;: [
                  3
              ]
          },
          &quot;2022-04-28&quot;: {
              &quot;dots&quot;: [
                  3
              ]
          }
      }
  }
  </code></pre>
  <p>Now I am using a library for react native (specifically react-native-calendars) and I need to reformat the response of my server, replacing within the object dots the numbers 1, 2, 3 of the static objects I have defined as follows :</p>
  <pre><code>const data1 = {
      key: &quot;data1&quot;,
      color: Colors.color40,
    };
    const data2 = {
      key: &quot;data2&quot;,
      color: Colors.colorYellow,
    };
    const data3 = {
      key: &quot;data3&quot;,
      color: Colors.color44,
    };
  
    const totalData = {
      1: data1,
      2: data2,
      3: data3,
    };
  </code></pre>
  <p>According to the react native calendars documentation, I need to have an object structured like this as a final result:</p>
  <pre><code>const vacation = {key: 'vacation', color: 'red', selectedDotColor: 'blue'};
  const massage = {key: 'massage', color: 'blue', selectedDotColor: 'blue'};
  const workout = {key: 'workout', color: 'green'};
  
  &lt;Calendar
    markingType={'multi-dot'}
    markedDates={{
      '2017-10-25': {dots: [vacation, massage, workout]},
      '2017-10-26': {dots: [massage, workout]}
    }}
  /&gt;;
  </code></pre>
  <p>To get the expected result, I wrote the following function:</p>
  <pre><code> const formattedCalendarDots = (obj) =&gt; {
          Object.keys(obj).forEach((key) =&gt; {
            obj[key] = { dots: obj[key].dots.map((el) =&gt; totalData[el]) };
          });
          return obj;
        };
  </code></pre>
  <p>I ask the more experienced. is this a good solution?
  Again, this function does what I ask, but I wanted to know if it was possible to optimize it in excellent performance.
  Thanks to those who will answer</p>