title: How to write an if else statement referencing which button (of multiples) was clicked in javascript
body: <p>I am writing a multiple choice quiz.  As it stands now, I have managed to identify which button is clicked by the user.  I'm now trying to write an if else statement based on that information.  Each question will have a different button represent the right answer, so ideally I'd like something like &quot;if id of button clicked !== correct, this, else this.&quot;  I've provided some of the code to give you an idea of where I'm trying to go with this.  All help appreciated!</p>
  <pre><code>//h1 will display the questions
  var quiz = [
      //quiz questions and potential answers here in this array
      Question1 = {
          question: &quot;this is question 1&quot;,
          //these will probably be changed into buttons
          answer1: &quot;wrong answer&quot;,
          answer2: &quot;wrong answer&quot;,
          answer3: &quot;right answer&quot;,
          answer4: &quot;wrong answer&quot;,
          correct: &quot;answer3&quot;
          
      },
      Question2 = {
          question: &quot;this is question 2&quot;,
          //these will probably be changed into buttons
          answer1: &quot;wrong answer&quot;,
          answer2: &quot;right answer&quot;,
          answer3: &quot;wrong answer&quot;,
          answer4: &quot;wrong answer&quot;,
          correct: &quot;answer2&quot;
  </code></pre>
  <pre><code>for (var i = 0; i &lt; allButtons.length; i++) {
              allButtons[i].addEventListener(&quot;click&quot;, function() {
                  console.clear();
                  console.log(&quot;you clicked: &quot;, this.innerHTML);
              });
  </code></pre>
  <p>For reference, in this case, &quot;answer1,&quot; answer2,&quot; etc correspond with the ids of the buttons</p>