title: Function that checks whether all characters in a string are equal javascript - Homework Warning
body: <p>I found a solution to this homework question, but I dont feel its the most efficient way to tackle the problem.  Interested in other solutions I should explore. </p>
  
  <p>Question: 
  Write a function named allEqual that returns true if every character in the string is the same</p>
  
  <p>Example:</p>
  
  <p>If you pass "aaa" it should return true
  If you pass "aba" it should return false
  */</p>
  
  <p>My Code</p>
  
  <pre><code>var stringAE = "aba";
  
  function allEqual(string) {
      var stringAENew = "";
      for (var i = 0; i &lt; string.length; i++) {
          if (string[0] === string[i]) {
              stringAENew += string[i];
              console.log(stringAENew)
          }
  
      }
      return stringAENew === string;
  }
  
  
  allEqual(stringAE) 
  </code></pre>