// Tests
const s = 'abcabcdbb';

function lengthOfLongestSubstring(s) {
  let longest = 0;
  let len = s.length;
  let i = 0;
  let j = 0;
  let map = {};
  while (i < len && j < len) {
    if (typeof map[s[j]] === 'undefined') {
      map[s[j]] = 1;
      j++;
      longest = j - i > longest ? j - i : longest;
    } else {
      delete map[s[i]];
      i++;
    }
  }
  return longest;
}

console.log(lengthOfLongestSubstring(s));

@@ -26,16 +26,156 @@
 cdbb';%0A%0A
+/**%0A * Given a string, find the length of the longest substring without repeating characters.%0A * @param  %7Bstring%7D s%0A * @return %7Bnumber%7D%0A */%0A
 function

Add substring comments