title: AlertIOS For loop
body: <p>I'm having an issue with AlertIOS </p>
  
  <pre><code>var array =[];
  for (var i = 1; i &lt;= sortedResult.length; i++) {      
    array.push({
      text: sortedResult[i].name,
      onPress: () =&gt; this.upload(i)
    });
  }
  AlertIOS.alert(
    'Question ?',
    null,
    array
  );
  </code></pre>
  
  <p>The problem is that the variable i in the for loop is not replaced by its value: </p>
  
  <pre><code>{text: sortedResult[i].name, onPress: () =&gt; this.upload(i)}
  
  {text: sortedResult[i].name, onPress: () =&gt; this.upload(i)}
  ...
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>{text: sortedResult[1].name, onPress: () =&gt; this.upload(1)}
  
  {text: sortedResult[2].name, onPress: () =&gt; this.upload(2)}
  ...
  </code></pre>
  
  <p>I don't know whether it is specific to javascript or specific to react.</p>
  
  <p>Thanks!</p>