title: Im making a personality quiz and need to convert answer codes to a word
body: <p>I'm trying to make a personality quiz and I want to convert the answer code I got (yes is an A and no is a B) its a simple 4 question personality quiz for kids. I have a function that puts all 4 questions &quot;identifiers&quot; (the A and B) into a string then I want to make an if statement that tells the program to output an answer based on that 4 letter code. So basically when it is AAAA the program needs to convert that to a Leopard(AAAA = Leopard) I have the code that outputs it to the HTML file I just need to convert that AAAA to a word.</p>
  <pre><code>function getEndingSentence() {
      var quizRadio = document.getElementsByName(&quot;rq&quot;);
      var answerCode = ''; //It's easier to handle if we simply merge all sentences into a string
      for (var i = 0; i &lt; quizRadio.length; i++) {
          if (quizRadio[i].checked) {
              answerCode += quizRadio[i].getAttribute(&quot;data-endingsentence&quot;); //these are the attributes used to generate quiz answers
          }
      }
      return answerCode;
  }
  
  function getAnswer() {
      var finalAnswer = ''
      var preAnswer = getEndingSentence();
      if (preAnswer = &quot;AAAA&quot;) {
      finalAnswer = 'Jagluiperd'
      } else {
          finalAnswer = 'Undefined'// just to test if the if statment works
      }
      return finalAnswer;
  }
  
  function setEndingSentence() {
      var personalityResults = getAnswer();
      document.getElementById(&quot;results_screen&quot;).className = &quot;&quot;;
      document.getElementById(&quot;generated_text&quot;).innerHTML = personalityResults; 
  
  } 
  </code></pre>