title: longest substring of non repeating characters javascript
body: <p>The problems asks "given a string, find the longest non-repeating sub-string without repeating characters". I am a little stumped why returning my code is not working for the string "dvdf" for example. Here is my code : </p>
  
  <pre><code>function lengthOfLongestSubstring(check) {
      var letters = check.split("");
      var max = 0;
      var result = [];
      for (var i = 0; i &lt; letters.length; i++) {
          var start = i
          if (result.indexOf(letters[i]) === -1) {
              result.push(letters[i])
          } else {
              i = i - 1
              result = []
          }
          if (max === 0 || max &lt; result.length) {
              max = result.length
          }
      }
      return max
  }
  </code></pre>