title: Finding keys equal to values not working
body: <p>Alright, so I was sitting around one day thinking about "What if I make my own encoding like Base64 in JavaScript?" and then I came up with the idea of creating a library that allows you to make your own encoding like Base64. This is the code I came up with:</p>
  
  <pre><code>var Zinc = Zinc || {};
  Zinc.Encoding = function(name) {
      this.encodingName = name;
      this.conversionTable = {};
      this.addToTable = function(string, convertsTo) {
          this.conversionTable[string] = convertsTo;
      };
      this.removeFromTable = function(string) {
          delete this.conversionTable[string];
      };
      this.encode = function(string) {
          var len = string.length;
          var out = string.split("");
          for (var i = 0; i &lt; out.length; i++) {
              out[i] = this.conversionTable[out[i]];
          }
          return out.join("");
      }
      this.decode = function(string) {
          var len = string.length;
          var dec = string.split("");
          var out = [];
  
          for (var i = 0; i &lt; dec.length; i++) {
              out[i] = this.getTableKeyByValue(dec[i]);
          }
  
          return out.join("");
      }
      /* Used internally. */
      this.getTableKeyByValue = function(value) {
          for (var prop in this.conversionTable) {
              if (this.conversionTable.hasOwnProperty(prop)) {
                  if (this[prop] === value)
                      return prop;
              }
          }
      };
  }
  
  window.Zinc = Zinc;
  </code></pre>
  
  <p>Encoding works and everything, just try this:</p>
  
  <p><code>var test = new Zinc.Encoding(); test.addToTable("j", "blah"); test.encode("j");</code></p>
  
  <p>And it outputs: <code>"blah"</code>.</p>
  
  <p>Try doing: <code>test.decode("blah")</code>, but it does not do anything, and returns "".
  Why does it do this instead of finding the key in the table object and getting the name that is equal to the value, and turn the value into the name that is equal to the value. (confusing, right?)</p>