title: How do you change a function name inside a for loop in javascript
body: <p>I want to change the function name inside of a for loop to something like this.</p>
  
  <pre><code>&lt;script&gt;
  for (var x=1;x&lt;10;x++){
  function name_x(){
     code
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>So, 10 functions are produced with the names name_1, name_2 etc.</p>
  
  <p>Thanks</p>
  
  <p>Edit:</p>
  
  <p>This is what I need a for loop around to create 5 functions id_1, id_2, id_3, id_4, id_5</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  function id_1(a){
  var id = document.getElementById(a);
  if (id.innerHTML==="innerHTML2"){
      id.innerHTML="innerHTML1";
  }
  else if (id.innerHTML==="innerHTML1"){
      id.innerHTML="innerHTML2";
  }
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;a id="id1" href="javascript:id_1('id')"&gt;innerHTML1&lt;/a&gt;
  &lt;a id="id2" href="javascript:id_2('id')"&gt;innerHTML1&lt;/a&gt;
  &lt;a id="id3" href="javascript:id_3('id')"&gt;innerHTML1&lt;/a&gt;
  &lt;a id="id4" href="javascript:id_4('id')"&gt;innerHTML1&lt;/a&gt;
  &lt;a id="id5" href="javascript:id_5('id')"&gt;innerHTML1&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>