Incrementing Click Redux Function in an array : <p>I am working with some svg elements and i have built an increment button.</p>

<p>The increment button takes the the <code>path d</code> values converts it into an array and sums <code>5</code> from the third element of the array. If the element is <code>'L'</code> or <code>'M'</code> it does nothing</p>

<p>Here the click function in the redux, it takes the values of the incrementing action state</p>

<pre><code>  const a = action.index;
  let string = state[a].d;
</code></pre>

<p>It converts in an array</p>

<pre><code>let array = string.split(" ");
</code></pre>

<p>and then it does all the calculation i said in the loop</p>

<p>See the full redux function</p>

<pre><code>  switch(action.type) {
    case 'INCREMENT_COORDINATES' :
      console.log("incrementing coordinaates")
      const a = action.index;
      let string = state[a].d;
      let array = string.split(" ");
      let max = array.length;
      let i = 3;
      let click = () =&gt; {
        i++;
        if ( i === max ) i = 3;
        if (array[i] !== 'M' &amp;&amp; array[i] !== 'L') array[i] = parseInt(array[i]) + 5;
        array.join(' ');
      };
      return [
        ...state.slice(0,a), // before the one we are updating
        {...state[a], d: click()}, // updating the with the click function
        ...state.slice(a + 1), // after the one we are updating
      ]
    default:
      return state;
  }
</code></pre>

<p>See the video demo while i debug it <a href="http://www.fastswf.com/uSBU68E" rel="noreferrer">http://www.fastswf.com/uSBU68E</a></p>

<p>As you can see the code does the right calculation and it sums <code>5</code> from the fourth element and it is returning the number <code>331</code>. So all good!But the problem is that i need to return it as <code>'331'</code>, a new element of the array to continue the loop.</p>

<p>I have built a demo which is perfectly working and doing what i want to achieve, using the same code! So i don't understand what i am doing wrong when i apply it in my redux function.</p>

<p>See the <a href="http://jsbin.com/tumesug/edit?js,console,output" rel="noreferrer">jsBin</a> perfectly working as i want.</p>
