title: Duplicate Encoder (duplicate letters in a string)
body: <p>The goal is to convert a string to a new string where each character in the new string is '(' if that character appears only once in the original string, or ')' if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate.</p>
  
  <p>my problem is if it's repeating a letter first parenthese is showing wrong.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function duplicateEncode(word){
  
    var repeat = [];
    var result = [];
    var letters = word.split('');
    for (i=0; i &lt; letters.length; i++){
        if (repeat.indexOf(letters[i]) &gt; -1) {
            result.push(")");
        } else {
            result.push("(");
        }
        repeat.push(letters[i]);
     }
     return result.join("");
   }
  console.log(duplicateEncode("aleluia"))</code></pre>
  </div>
  </div>
  </p>