title: Two buttons calling the same function, how to know which button called
body: <p>I created a function that makes buttons because I have to make several:</p>
  
  <pre><code>makeButton(function, "text")
  </code></pre>
  
  <p>The parameters are the function it will be calling "onclick" and the text that will show on the button.</p>
  
  <p>Now I have two of them calling the same function but I want the function to behave in one way if one calls and other way if the other is calling.</p>
  
  <p>I tried to call the function like this:</p>
  
  <pre><code>makeButton(function(flag = true), "text")
  </code></pre>
  
  <p>And then in the function:</p>
  
  <pre><code>if(flag == true) doSomething;
  else doSomethingElse;
  </code></pre>
  
  <p>Maybe this won't work, but the thing is when I create the button like this:</p>
  
  <pre><code>makeButton(function(flag = true), "text")
  </code></pre>
  
  <p>It executes the function when creating the button, and I wanted it to execute only onclick.</p>
  
  <p>Other thing I thought was in the function:</p>
  
  <pre><code>if(buttonA) do something;
  if(buttonB) do somethingElse;
  </code></pre>
  
  <p>But I need the function to know which button has called for it...</p>
  
  <p>Do you have any suggestion to do this in other way?
  Only simple JavaScript please!</p>
  
  <p>The function looks like this:</p>
  
  <pre><code>function makeButton(function, text){
    var button = document.createElement('BUTTON');
    var btTxt = document.createTextNode(text);
    button.style.color = '#006633';
    button.style.fontWeight = 'bold';
    button.onclick = function;
    button.appendChild(btTxt);
    button.style.margin = '5px';
    document.body.appendChild(button);
  }
  </code></pre>